How to fetch remote branch in GIT?

Published on Author Code Father

You need to create a local branch that tracks a remote branch. The following command will create a local branch named daves_branch, tracking the remote branch origin/daves_branch. When you push your changes the remote branch will be updated.

For most versions of git:

git checkout --track origin/daves_branch

–track is shorthand for git checkout -b [branch] [remotename]/[branch] where [remotename] isorigin in this case and [branch] is twice the same, daves_branch in this case.

For git you needed this:

git checkout --track -b daves_branch origin/daves_branch

For git and higher this is enough (might have started earlier but this is the earliest confirmation I could find quickly):

git checkout daves_branch

full details here:



Categories Git