Gabriel
Gabriel

Reputation: 42449

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

Upvotes: 0

Views: 1079

Answers (1)

jacob1123
jacob1123

Reputation: 361

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.

Upvotes: 3

Related Questions