Reputation: 1039
My ideal workflow would consist of the following steps
I cannot use git commit -a --amend -m "new commit message"
, because this commits the new changes as well. I'm not sure that I want to bother with staging or branching. I wish I could just edit the commit message without committing any new changes. Is it possible?
Upvotes: 7
Views: 3477
Reputation: 5123
You can also use:
git rebase -i HEAD^
This will open up your text editor and let's you change the last commit. You need to replace the word pick
in the beginning of the line with reword
, save the file and exit. After that a new text editor will open up that let's you change the commit message.
That sounds a bit more work than the suggested git commit --amend
approach, but works also for older commites. So if you found that you want to change two messages in the last ten commits, you can run git rebase -i HEAD~10
and change the word pick
again into reword
and change both of those messages.
Just for the curious: -i
stands for interactive rebasing.
Upvotes: 2
Reputation: 7494
There's no need to stash or do anything else here.
git commit --amend -m 'Your new message.'
will not commit any new changes (note the lack of -a
flag), provided that you haven't explicitly added them to the index (using git add
, for example).
Upvotes: 16
Reputation: 35191
Just:
$ git stash
$ git commit --amend -m "Your Modified Message"
$ git stash apply
Upvotes: 4