使用git rebase时自动跳过空提交

时间:2012-06-20 20:36:12

标签: git git-rebase

通常,你必须做git rebase --skip,如果有一个自动跳过这些空提交的开关会很好。有人知道怎么做吗?

1 个答案:

答案 0 :(得分:1)

G2 - 使用以下别名continue

网址到G2 - https://github.com/orefalo/g2 备忘单 - 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
}