Git is a version control system.
Git helps you keep track of code changes.
Git is used to collaborate on code.
Git –version
Git and GitHub are different things.
In this tutorial you will understand what Git is and how to use it on the
remote repository platforms, like GitHub.
Github
BitBucket
GitLab
t is used for:
Tracking code changes
Tracking who made changes
Coding collaboration
What does Git do?
Manage projects with Repositories
Clone a project to work on a local copy
Control and track changes with Staging and Committing
Branch and Merge to allow for work on different parts and versions of
a project
Pull the latest version of the project to a local copy
Push local updates to the main project
Git is not the same as GitHub.
GitHub makes tools that use Git.
GitHub is the largest host of source code in the world, and has been
owned by Microsoft since 2018.
Create account in github and create a repository
Download the git and install it …open command prompt and check
git
Git –version
How to get the file from git repository to the local repository
Open the terminal in the vscode
Git clone
Copy the link of ur repository
Cd ur foldername
---go to the git local repository there u can go to view and show the hidden
files
U can view .git folder this act as a bridge between the local
and github repository
--next task is to upload the test file from local to github
--once u create a file in vscode ---U -unmodified it shows
Git status
Git add test1.txt
U changed to A
----git add test1.txt
--git commit -m “test1.txt added”
Now from staging area to git copy folder after commit has done
Now need to move the file from git copy folder to github
Git push origin main
--now file moved to git copy folder to github
Insert – add ---commit---push
Now delete one file from local –it will not reflect in the repo
Git add test2.txt
Git commit -m “file deleted”
Git push origin main
Create a file in github repository now pull the file to the local
Git pull
---we don’t need to use clone because we don’t need to get the entire
repository
Any modification------add—commit---pull
Now create folder in the local repo and create a index.html file in it
Move back the folder cd..
Cd newfoldername
Git init
Git add .
Git commit -m “add both files”
Git push origin main ----but here its not possible
So create a repository in github and connect using the below command
git remote add origin https://github.com/RemyaAravind/Gitting.git
git branch –it shows master
git branch -M main
git push origin main
git branch -a –list all branches
create a new branch in git repository
git checkout newbranch ---this command helps to move from main
branch to new branch
now create a file and do the add,commit and push
git push origin newbranch
to know the difference between two branches
---switch to main branch
Git checkout main
Git diff newbranch
Going to merge new branch with the main branch
Git merge newbranch
Git push origin main
Create a new branch
Git branch newbranches
Git push newbranches---it reflect now in github
Pull request ---we don’t have the right to access the main
----create pull request from newfolder
----from the main do the pul request and merge it
Conflict --when both try to change the same file at the same time
---create a new repository –mergeconflic
----create 2 branches –branch1 ,branch2
-----create a file test.txt –give the content city:None
-----now go the branch 1 change the content city:Banglore
-----braanch2 has the content city:Chennai
---now pull request and merge main and branch1
Now when trying to merge branch2 with main ,conflict occurs
----so manually correct the content and merge it with the main