Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically skip empty commits when using git rebase

Tags:

git

git-rebase

Usually, you have to do git rebase --skip, it would be nice if there was a switch to automatically skip over these empty commits. Anyone know how to do this?

like image 690
quinn Avatar asked Jun 20 '12 20:06

quinn


People also ask

How do I skip a commit in rebase?

Sometimes during a Git rebase process, you may encounter some conflicting commits and wants to skip the specific commit for some reason. You can do that by passing the --skip flag in the git rebase command.

What does git rebase -- skip do?

You can run git rebase --skip to completely skip the commit. That means that none of the changes introduced by the problematic commit will be included. It is very rare that you would choose this option. You can fix the conflict.

Does rebase create new commits?

The Rebase Option But, instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch.

Do I need to commit before git rebase -- continue?

For each change you make, you'll need to perform a new commit, and you can do that by entering the git commit --amend command. When you're finished making all your changes, you can run git rebase --continue . As before, Git is showing the commit message for you to edit.


1 Answers

Very old topic, but for me was the first result on the search engine.

I finally found there is a --empty parameter that can take one of the following values: keep, drop, and ask.

Link to the documentation: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---emptydropkeepask

So you now can simply do git rebase ... --empty=drop

like image 53
txigreman Avatar answered Oct 22 '22 08:10

txigreman