git commit --amend without asking for message
24,150
Solution 1
Try git commit --amend --no-edit
.
Solution 2
This will amend the latest commit, using that same message, in one command:
git commit --amend -C HEAD
Author by
talles
Updated on February 21, 2020Comments
-
talles about 4 years
From time to time I find myself commit-amending using the same message.
Typically, I do:
- Add my changes to staging area.
- Do
git commit --amend
. - Wait for the text editor to open.
- Save and close it (without changing the message).
There is anyway to tell git that I don't want to change the commit message (skipping the step of opening my text editor and saving the message)? Like:
- Add my changes to staging area.
- Tell git to amend my staging area to the last commit without asking me for another message.
I know I can avoid git firing up my text editor by doing
git commit --amend -m "<message>"
. But this way I would have to retype the message. -
crsuarezf over 8 yearsThis option works perfectly on centOS 6.7 (final). because --no-edit option is not yet avaiable in that platform, through a standard git yum install. NOTE: git version 1.7.1
-
meustrus over 7 yearsFrom stackoverflow.com/a/10365442/710377: This option was added in Git 1.7.9.
-
Pat Myron over 5 yearsNote: The --no-edit flag was added in Git 1.7.9: github.com/git/git/blob/… The other answer will work for previous Git versions