为什么`git cherry-pick --allow-empty`没有作用? [英] Why does `git cherry-pick --allow-empty` have no effect?

查看:557
本文介绍了为什么`git cherry-pick --allow-empty`没有作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我选择不做任何更改的提交,但是我希望它仍然进行提交(这样提交的审核跟踪与另一个项目一致),我会收到消息:

If I cherry-pick a commit which makes no changes, but I want it to commit anyways (so that the audit trail of commits is consistent with another project), I get the message:

$ git cherry-pick 696abcb

什么也没提交,工作目录干净 现在,以前的选择是空的,可能是由于解决冲突的缘故. 如果仍要提交,请使用:

nothing to commit, working directory clean The previous cherry-pick is now empty, possibly due to conflict resolution. If you wish to commit it anyway, use:

git commit --allow-empty

根据手册页,我可以将--allow-empty与Cherry-pick一起使用.但这会导致相同的消息:

According to the man pages, I can use cherry-pick with --allow-empty. But this results in the same message:

$ git cherry-pick --allow-empty 696abcb

(与上述消息相同)

这是一个错误吗?我是否完全误解了此选项的目的?

Is this a bug? Am I completely misunderstanding the point of this option?

推荐答案

由于没有什么可以选择的,因此无法完成任何工作.您唯一可能做的就是创建一个空的 commit . 不是指示您运行git cherry-pick --allow-empty,而是指示您运行:

Since there's nothing to cherry-pick, there's no work that can be done. The only possible thing that you could do is create an empty commit. It's not instructing you to run git cherry-pick --allow-empty, instead it's instructing you to run:

git commit --allow-empty

请注意,这是 commit 命令. git默认情况下不会创建没有更改的提交.

Note that's the commit command. git will not, by default, create commits with no changes in them.

(git质疑创建一个空提交的价值,只是为了在您的历史记录中包含一个提交消息(坦率地说,我也是如此),但是如果您需要它来进行审核,那么这就是这样做的方法.)

(git questions the value of creating an empty commit, just to include a commit message in your history - as do I, to be frank - but if you need it for auditing, then this is the way to do it.)

这篇关于为什么`git cherry-pick --allow-empty`没有作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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