使用git rebase时自动跳过空提交 [英] Automatically skip empty commits when using git rebase

查看:471
本文介绍了使用git rebase时自动跳过空提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,您必须执行 git rebase --skip ,如果有切换到自动跳过这些空提交会很好。有人知道怎么做吗?



网址为G2 - https:// github。 com / orefalo / g2
Cheatsheet - http://orefalo.github.com/g2 /

 #!/ bin / bash 

#此命令用于恢复冲突,重组或者合并
#它会巧妙地做一次rebase - 必要时跳过

state = $($ GIT_EXEg2brstatus)

[[$ state =rebase]]&& {

action = - continue
如果git diff-index --quiet HEAD - ;然后
echo最后一次提交没有带来重大变化 - 跳过
action = - skip
fi

$ GIT_EXErebase $ action 2> ; / dev / null

}

[[$ state =merge]]&& {
#计算未合并文件的数量
count = $($ GIT_EXEls-files --unmerged | wc -l)
[[$ count -ne 0]]& &安培;回声恐怕你仍然有未合并的文件,请运行< g mt>来解决冲突||$ GIT_EXEcommit
}


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?

解决方案

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
} 

这篇关于使用git rebase时自动跳过空提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆