1

I am using git for quite some time and wanted to use rebase command. Earlier I have used only the merge command.

I have my changes done to my feature branch which I need to merge with my master branch. I can go ahead and merge my changes to my master branch by running the git merge command from the master branch. But can I use the rebase command to get my branch changes into my master? From the documentation, I understood that rebase will be done from the feature branches to merge the changes from the master to my feature branch. Is my understanding correct or I need to use the git merge command for my scenario.

zilcuanu
  • 3,451
  • 8
  • 52
  • 105

1 Answers1

5

But can I use the rebase command to get my branch changes into my master?

Yes:

git checkout feature
git rebase master  # replay feature commits on top of master
git checkout master
git merge feature # fast-forward

Make sure you are the only one working on that branch, as a rebase will change (rewrite) its history, and you will need a git push --force to publish your work.

See more at:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250