Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between checkout remote branch and pull remote branch in git?

What is the difference between:

git checkout -b <branch> origin/<branch>

and

git pull origin <branch>

They seem to have the same functionality to me. thanks.

like image 665
makansij Avatar asked Feb 22 '15 21:02

makansij


1 Answers

git pull contacts the remote repository identified by origin and looks for updates. It fetches any updates and then merges the changes into the target branch. It does not create a new branch.

git checkout -b <branch> origin/<branch> creates a new branch based on origin/<branch>, and does not contact the remote repository. It looks at origin/<branch> as it currently exists in your local repository.

The two commands perform very different actions; spending some quality time with the git-pull and git-checkout man pages might help clarify things.

like image 121
larsks Avatar answered Sep 23 '22 18:09

larsks