Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rebase while skipping a particular commit?

Is there a way to rebase a branch onto another while skipping a particular (conflicting) commit on the other branch?

For example, I want to rebase mybranch onto master, but master contains a commit that will conflict with the commits in master, so I prefer to undo that commit completely.

-o-o-o-o-o-x-o-o-o-o master      |      o-o-o-o mybranch 

x marks the conflicting commit.

like image 870
Phillip Avatar asked Sep 26 '12 15:09

Phillip


People also ask

What happens if you git rebase skip?

If you run rebase --abort at a later conflict during the same rebase, the skipped commit will be reverted too of course. If your change already existed upstream, Git will not be able to apply your commit (but usually should skip it automatically, if the patch is exactly the same).

Does rebase need commit?

The purpose of rebase is make your commits look as if they were changes to the branch you rebase onto. So the most logical way is to incorporate merge conflicts into these commits. No additional commits is required thus.


1 Answers

Use interactive rebase:

git rebase -i master 

An editor will open and you will have a list of commits like this:

pick b8f7c25 Fix 1 pick 273b0bb Fix 2 pick 6aaea1b Fix 3 

Just delete the commit you want to skip. It will be omitted while rebasing your branch onto master.

P.S. If you cannot see the editor, please, refer to this question for solution: How can I set up an editor to work with Git on Windows?

like image 92
Sergey K. Avatar answered Oct 20 '22 21:10

Sergey K.