简体   繁体   English

编辑上次推送提交的消息

[英]Edit last pushed commit's message

After making use of the command to stage, commit and push all at once I asked for here Git command to commit all changes including files removed or created , I've typed the wrong commit message and then pushed it to my Github account. 在使用命令进行暂存,提交和推送之后,我在这里要求Git命令提交所有更改,包括删除或创建的文件 ,我输入了错误的提交消息,然后将其推送到我的Github帐户。 I'm the only contributor to my repo so there's no pulling issues to fear. 我是唯一贡献我的回购,因此没有拉动问题的恐惧。

I've followed the advice given here Changing git commit message after push (given that no one pulled from remote) and here Edit an incorrect commit message in Git that has already been pushed which is basically to do: 我遵循了这里给出的建议在推送之后更改git commit消息(假设没有人从远程拉出)并在这里编辑一个已经被推送的Git中的错误提交消息,这基本上是这样做的:

git commit --amend

which opens up my text editor (Sublime) displaying the message of the last commit. 这将打开我的文本编辑器(Sublime),显示上次提交的消息。 Once in there I modify this message, save and close the file. 在那里我修改此消息,保存并关闭文件。 After that I type: 之后我输入:

git push origin master --force

which appears to work fine. 这似乎工作正常。 But if I now do a : 但如果我现在这样做:

git log

I keep seeing the wrong (ie: the old) message in my last commit and my Github account shows no changes whatsoever. 我在上次提交时一直看到错误的(即:旧的)消息,我的Github帐户显示没有任何变化。 What am I doing wrong? 我究竟做错了什么?

In my experience Sublime doesn't work well with git propmts. 根据我的经验,Sublime与git propmts不兼容。 Try passing the correct message directly with 尝试直接传递正确的消息

git commit --amend -m <message>

and see if it works. 看看它是否有效

If it does you might have to switch to gVim or some other editor, that uses a single process. 如果是这样,您可能必须切换到使用单个进程的gVim或其他编辑器。

I don't exactly know what the problem is with Sublime Text but I guess the first process just spawns another one and quits. 我不完全知道Sublime Text的问题是什么,但我想第一个进程只会生成另一个进程并退出。 Because of this git thinks the editing is finished and commits before you actually modified the file. 由于这个git认为编辑已完成并在您实际修改文件之前提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM