When I write git commit --amend
I get some kind of editor, where I can change the name of this commit. How to confirm and save my changes using keyboard?
To find out which files changed in a given commit, use the git log --raw command.
Amended commits are actually entirely new commits and the previous commit will no longer be on your current branch. This has the same consequences as resetting a public snapshot. Avoid amending a commit that other developers have based their work on.
Expanding on what William Pursell said, you probably ended up in vim. Save your changes and exit the editor by typing :
to enter a command, followed by wq
, then press enter. To exit vim without saving your changes do :q!
instead.
To change this default to something you're more familiar with, you can set the EDITOR
variable to something of your choice (try nano
).
Just put export EDITOR=nano
at the end of ~/.bash_profile
(create the file if you don't already have it) to get this behaviour for every new terminal session.
Also, you could do git commit --amend -m 'Your message here'
without a need for an editor at all.
Configure the editor like this (gedit as an example):
git config --global core.editor "gedit"
You can read the current configuration like this:
git config core.editor
You can also add the commit message from the command line.
git commit --amend -m "blablabla"
and the editor will not be opened at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With