Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly does `git rebase --skip` skip during a rebase?

Tags:

git

When you perform a rebase, git asks for manual intervention if it can't resolve differences between your current branch and the new base branch.

If you resolve conflicts and type git rebase --continue, git treats the resolved code as the 'new code' for that commit.

But what happens when you hit git rebase --skip? It can't leave the code as it is—there are conflicts—so it must be doing something more than just 'skipping'.

like image 325
achalk Avatar asked Jan 18 '18 15:01

achalk


People also ask

What happens during rebase?

From a content perspective, rebasing is changing the base of your branch from one commit to another making it appear as if you'd created your branch from a different commit. Internally, Git accomplishes this by creating new commits and applying them to the specified base.

Does rebase avoid merge conflicts?

Rebasing is not going to magically remove all merge conflicts. In fact, you may encounter conflicts while rebasing. Sometimes, you will have to repeatedly resolve the same conflict while rebasing. However, merge conflicts happen because multiple changes happen to the same chunk of code simultaneously.

How do you break a rebase?

To interrupt the rebase (just like an " edit " command would do, but without cherry-picking any commit first), use the " break " command.


1 Answers

If there is a conflict, git rebase --skip simply skips the entire commit. The changes from that commit will not be in the history after the rebase finishes successfully. Let's look at an example

A-B-C <- master
 \
  D-E <- foo

Now say D causes a conflict after

git checkout foo
git rebase master

Then git rebase --skip results in

A-B-C <- master
     \
      E' <- foo

where E' contains the same textual changes as E.

like image 50
Code-Apprentice Avatar answered Sep 22 '22 05:09

Code-Apprentice