推空提交到远程 [英] Pushing empty commits to remote
问题描述
我将一个提交推送到远程,但现在我意识到提交消息是不正确的。我想改变提交信息,但AFAIK是不可能的。所以我决定用正确的消息创建空的提交:
I have pushed one commit to remote but now I realized that the commit message is not correct. I would like to change the commit message but AFAIK it is not possible. So i decided to create empty commit with correct message:
git commit --allow-empty
推送空提交是否存在任何缺点/后果?是否有任何问题我将来可能会面临因为这个空的提交?
Are there any disadvantages/consequences of pushing empty commits? Is there any problem I might face in future because of this empty commit??
推荐答案
您不会面临任何可怕的后果,
You won't face any terrible consequence, just the history will look kind of confusing.
您 可以 通过更改提交消息
You could change the commit message by doing
git commit --amend
git push -f
但这会覆盖您的远程历史记录,这意味着如果有人在此期间拉回该回购,此人会对您感到生气...
BUT this will override the remote history with yours, meaning that if anybody pulled that repo in the meanwhile, this person is going to be very mad at you...
如果您是唯一访问回购站的人,请执行此操作。
Just do it if you are the only person accessing the repo.
这篇关于推空提交到远程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!