我一直在使用这个git-alias,它是我在这里的一个问题中得到的:
wip = !f() { git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "wip";}; f
所以现在我有了一系列的n个提交,它们都包含'wip‘本身作为提交消息。
我如何创建一个git别名来找到正确数量的提交,然后返回包含"wip“的树并压缩它们?这真的可能吗?
发布于 2011-11-22 22:39:28
您可能需要以交互方式提交和压缩现有的wip提交。由于带有压缩的rebase将改变历史,这使得自动化变得困难(尽管不是不可能);最好是逐个案例地使用rebase。完成此操作后,您可以将wip别名更改为以下内容:
git config --global alias.wip '!f() { git add -A; git ls-files --deleted -z | xargs -0 -r git rm; s=`git show --format=%s HEAD | head -1`; if [ "wip" = "$s" ]; then git commit --amend -m "wip"; else git commit -m "wip"; fi;}; f'这将避免您的历史记录中出现连续的wip提交。通过使用xargs -r option从原始别名更改别名,以便If the standard input is completely empty, do not run the command.,如果当前的HEAD提交主题是wip,则使用commit的--amend。
https://stackoverflow.com/questions/8226278
复制相似问题