如何在 RubyMine 中更改过去的 git commit+push 消息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15863269/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to change a past git commit+push message in RubyMine?
提问by Davit
I accidentally gave a wrong message and pushed a commit with it using RubyMine. Is there any way I can correct it? RubyMine way would be preferred not to mess up git, but other trusted ways are also welcome.
我不小心给出了一条错误消息,并使用 RubyMine 推送了一个提交。有什么办法可以纠正它吗?RubyMine 方式最好不要弄乱 git,但也欢迎其他受信任的方式。
回答by Max Beikirch
As you said, you already pushed, so it's wise not to change the commit message. The reason for that is that the commit will get another hash which makes git think that the commit you already pushed and the commit whose commit message you changed are different. That is bad! You can force push with git push -f
and that's absolutely okay if you are working alone, but if you are working in team, I suggest you not to change that commit message.
正如您所说,您已经推送了,因此最好不要更改提交消息。这样做的原因是提交将获得另一个散列,这使 git 认为您已经推送的提交和您更改其提交消息的提交是不同的。那很不好!您可以强制推送,git push -f
如果您单独工作,这绝对没问题,但如果您在团队中工作,我建议您不要更改该提交消息。
For anything else, take a look here: How to modify existing, unpushed commits?
对于其他任何事情,请看这里:如何修改现有的、未推送的提交?