20

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?

1
  • It's a pain in the neck indeed. I just want to get the latest code asap and not be bothered with such a minor thing that can be fixed later. Apr 13, 2018 at 21:46

2 Answers 2

6

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

2
  • Very cool, I wonder when this flag was added
    – quinn
    Mar 18, 2022 at 2:01
  • 1
    Would be nice to have this also for other commands like am :( Git is a mess in command parameters, not many consistency...
    – jaques-sam
    Apr 11, 2022 at 8:59
2

G2 - uses the following alias continue

Url to G2 - https://github.com/orefalo/g2 Cheatsheet - http://orefalo.github.com/g2/

#!/bin/bash
#
# This command is used to resume a conflict, either rebase or merge
#  it will smartly do a rebase --skip when necessary

state=$("$GIT_EXE" g2brstatus)

[[ $state = "rebase" ]] && {

action="--continue"
if git diff-index --quiet HEAD --; then
    echo "The last commit brings no significant changes -- skipping"
    action="--skip"
fi

"$GIT_EXE" rebase $action 2> /dev/null

}

[[ $state = "merge" ]] && {
# Count the number of unmerged files
count=$("$GIT_EXE" ls-files --unmerged | wc -l)
[[ $count -ne 0 ]] && echo "I am afraid you still have unmerged files, please run <g mt> to resolv conflicts" ||"$GIT_EXE" commit
} 
2
  • 2
    That seems very helpful, but I'm looking to do it once at the beginning, something like "git rebase --skip-empty" rather than stop on each one. I will try this though if nothing else turns up
    – quinn
    Jun 20, 2012 at 20:52
  • I don't know of any flags on rebase. remember you skip after a conflict resolution and git expects you to know if you should rebase or continue. g2 fixes that issue by figuring it out for you. You may change the script to you likings. Jun 21, 2012 at 0:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.