25

I work in develop branch. Sometimes, when I want to push changes to origin, git say, that there are some changes in origin/master branch.

How to pull changes from remote master to local master without checkout to local master?

cexbrayat
  • 16,462
  • 3
  • 26
  • 22
nkuhta
  • 9,358
  • 12
  • 36
  • 54
  • Some more answers in a possible duplicate http://stackoverflow.com/questions/18994609/how-to-git-pull-into-a-branch-that-is-not-the-current-one – Olga Mar 17 '17 at 11:17

2 Answers2

42

If you want to update your local master without checkout, you can do :

git pull origin master:master

That will update your local master with the origin/master

Or, as I assume that you want to ultimately rebase your develop branch with the changes occured in origin/master, you can do a simple git fetch, that will not touch your local branches :

git fetch

Now your origin/masteris up to date, so you can rebase or merge your local branch with these changes. For example, when you are in your develop branch :

git rebase origin/master

And your develop branch will be up to date with the changes.

cexbrayat
  • 16,462
  • 3
  • 26
  • 22
  • 8
    `git pull origin master:master` also pulls changes to your local develop branch – James Lin Jul 06 '15 at 22:08
  • Then either this answer should include the impact on local branch or modify the answer to something else. I would ask the original acceptor of this answer needs to unmark first and verify to give accept again. – swcraft Nov 16 '18 at 15:36
0

Accepted answer will also pulls master into your actual branch.

git fetch
git branch -D master
git checkout --track origin/master
Melounek
  • 634
  • 4
  • 18