- Linking your local repository (the one on your computer) to remote repositories on GitHub
- If you clone a repository, the command automatically adds that remote repository under the name
origin.
- The git commands
fetch,pull,merge,pushandsync
-
The command
git fetch originfetches any new work that has been pushed to that server since you cloned (or last fetched from) it. -
The
git fetchcommand only downloads the data to your local repository. -
If I want get changes from the remote repository called
origininto my local repository I typegit fetch origin. -
It doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
-
the
git pullcommand is agit fetchcommand followed by agit mergecommand. -
Git sync does everything in one command meaning pull and push read here
- Branching
-
To view the branches in a Git repository, run the command
git branch -
To see both local and remote branches use
git branch -aorgit branch --all -
To see details of each brach use
git branch -vorgit brach --verbose -
git checkout -b BRANCH_NAMEcreates a new branch and checks out the new branch -
git branch BRANCH_NAMEcreates a new branch but leaves you on the same branch. -
In other words
git checkout -b BRANCH_NAMEdoes the following for you:git branch BRANCH_NAME # create a new branchgit switch BRANCH_NAME # then switch to the new branch