git pull on a different branch

We can fetch changes from another branch in the same repository using git pull command like this:

$ git pull origin <target-branch>

See the EXAMPLES section of man git-pull :

   •   Merge into the current branch the remote branch next:

           $ git pull origin next

You could also try this:

git fetch
git merge origin/master

This won't update your local master pointer, but it will merge the latest origin/master into your current local branch.


I found an incantation that worked for me:

git fetch origin master:master

then (if you want to merge right away):

git merge master

I was really surprised how hard it was to find an answer to this since it seems like it would be a common use case.


Try this:

git pull yourRepositoryName master

Tags:

Git