5

Currently when I'm working on my local feature branch in order to get latest changes I need to do the following:

git checkout master
git fetch
git rebase
git checkout my-feature
git rebase master

Is there a simplier solution to just pull changes to master branch without switching to it?

Zoe
  • 27,060
  • 21
  • 118
  • 148
Sly
  • 15,046
  • 12
  • 60
  • 89

2 Answers2

1

I think Git will always switch to master behind the scene, to perform the rebase (considering that rebase starts by a checkout of the destination branch:
see "git rebase, keeping track of 'local' and 'remote'").

You just can use the shortcut git pull --rebase:

git pull --rebase master:master
git checkout my-feature
git rebase master
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

I think you can just do agit fetch followed by a git rebase origin/master That should rebase your topic-branch against master. Don't know if the fetch is really necessary though.

MartinH
  • 11
  • 3
  • 1
    The fetch is required as you probably want to get the modifications from origin. Rebase origin/master is a "shortcut": your feature branch will then be both : rebased with regards to origin/master and ahead of your local master. Your local master will _not_ be updated to the state of origin/master which was the original question – Jean Jul 03 '12 at 07:55
  • Ah sorry, I missed the question below the code. I thought Sly only wanted to update his topic-branch without touching his own master. – MartinH Jul 03 '12 at 08:04