Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to confirm changes after `git commit --amend` in Terminal? [duplicate]

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?

like image 831
Bartłomiej Semańczyk Avatar asked Jan 27 '15 17:01

Bartłomiej Semańczyk


People also ask

How do you see what changes were made in a git commit?

To find out which files changed in a given commit, use the git log --raw command.

What happens when you amend a commit?

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.


2 Answers

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.

like image 186
Travis Avatar answered Oct 04 '22 01:10

Travis


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.

like image 44
Martin G Avatar answered Oct 03 '22 23:10

Martin G