Git 别名用于压缩具有特定提交消息的所有提交
我一直在使用这个 git-alias,这是我从这里的一个问题中得到的:
wip = !f() { git add -A; git ls-files --deleted -z | git ls-files --deleted -z | git ls-files --deleted -z | xargs -0 git rm; git commit -m“wip”;}; f
所以现在我有一系列的 n 个提交,按顺序,它们都包含“wip”作为提交消息。
我如何创建一个 git 别名来找到正确数量的提交备份包含“wip”的树并压缩它们?实际上可能吗?
I've been using this git-alias which I got from a question on here:
wip = !f() { git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "wip";}; f
So now I have a series of n commits, sequentially, which all contain 'wip' on its own as the commit message.
How do I make a git alias to go about finding the right number of commits back up the tree which contain "wip" and squashes them? Is it actually possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要以交互方式
rebase
并压缩现有的wip
提交。由于带有挤压的rebase
会改变历史,因此很难(尽管并非不可能)实现自动化;最好根据具体情况进行rebase
。执行此操作后,您可以将wip
别名更改为以下内容:这将避免历史记录中出现连续的
wip
提交。使用xargs
-r
选项,以便如果标准输入完全为空,则不运行该命令。
并且如果当前HEAD
提交主题是wip
,使用commit
的--amend
。You will probably need to interactively
rebase
and squash the existingwip
commits. Since arebase
with squashes will change history, it makes it difficult (though not impossible) to automate; it's best torebase
on a case-by-case basis. After doing this, you can change yourwip
alias to the following:This would avoid contiguous
wip
commits in your history. The alias is changed from your original alias by using thexargs
-r
option so thatIf the standard input is completely empty, do not run the command.
and if the currentHEAD
commit subject iswip
, usecommit
's--amend
.