编辑上次推送的提交消息 [英] Edit last pushed commit's message

查看:142
本文介绍了编辑上次推送的提交消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用命令执行阶段之后,一次提交并全部推送,我在这里要求 Git命令提交所有更改,包括删除或创建的文件,我输入了错误的提交信息,然后将其推送到我的Github帐户。我是我回购的唯一贡献者,所以没有问题来担心。



我遵循这里给出的建议推后更改git提交消息(给定没有人从远程拉)和这里在Git中编辑一个不正确的提交消息,这已经被推送了,这基本上是这样做的:

  git commit --amend 

打开我的文本编辑器(Sublime)显示上次提交的消息。一旦在那里我修改此消息,保存并关闭文件。之后,我输入:

  git push origin master --force 

这似乎正常工作。但如果我现在做一个:

  git log 

我在上次提交中看到错误的(即:旧的)消息,我的Github帐户显示没有任何更改。我在做什么错了?

解决方案

根据我的经验,Sublime不适合使用git propmts。
尝试直接传递正确的消息

  git commit --amend -m< message> 

并查看它是否有效。

如果是这样,您可能不得不切换到使用单个进程的gVim或其他编辑器。



我不完全知道Sublime Text存在什么问题,但我想第一个过程会产生另一个并退出。因为这个git认为编辑已经完成并且在你实际修改文件之前提交。


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. 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 --amend

which opens up my text editor (Sublime) displaying the message of the last commit. 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. What am I doing wrong?

解决方案

In my experience Sublime doesn't work well with 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.

I don't exactly know what the problem is with Sublime Text but I guess the first process just spawns another one and quits. Because of this git thinks the editing is finished and commits before you actually modified the file.

这篇关于编辑上次推送的提交消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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