Home > Net >  git rebase ignore conflicts
git rebase ignore conflicts

Time:11-21

I have a branch with lots (400 ) of small, mostly independent, changes on it that were generated by a refactoring/linting tool.

I've used git bisect to isolate a commit that has caused a test failure.

I wish to rebase all of the commits after the offending one to just before it, effectively ignoring that suggestion. However, some (usually less than 3) of the other commits will depend on that change.

Is there a way to tell rebase to just skip/ignore any commits that would conflict and keep the rest?

CodePudding user response:

You can skip a commit when rebasing with git rebase --skip.

A naive approach would to just skip all commits that is stopping the rebase:

while git rebase --skip; do :; done

The above is a small piece of shell code, that will execute the command line git rebase --skip until it fails.

It doesn't fail, when it cannot apply a change, but rather stops the rebase. It will however fail when you are not doing a rebase, which is the case when everything have been rebased.

: is just an empty command, doing nothing but exiting successfully. It's used because a while loop in shell scripts needs a body.

  • Related