Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force git rebase on top of master?

Tags:

git

While rebasing git rebase master I notice there are conflicts. I don't care the changes that was made to master, I just want to put my current branch on top of master. How to force rebase so that your current branch is on top of master?

like image 776
Cory Avatar asked Oct 19 '16 00:10

Cory


People also ask

How do you rebase on top of the Masters?

To rebase, make sure you have all the commits you want in the rebase in your master branch. Check out the branch you want to rebase and type git rebase master (where master is the branch you want to rebase on).

Can you force a rebase?

By default, the git pull command performs a merge, but you can force it to integrate the remote branch with a rebase by passing it the --rebase option.


1 Answers

I think this should do the trick:

git rebase -s recursive -X theirs master

It will rebase your current branch onto master using the default recursive strategy.

The -X theirs switch applies the theirs option to the strategy, which means if it hits a conflict, it will automatically overwrite 'our' changes with 'their' changes. In this rebase, 'our' changes are the ones on master (the rebase 'root') and 'their' changes are those which are being rebased onto master (the ones from your current branch).

like image 120
Peter Avatar answered Oct 15 '22 19:10

Peter