As a newbie git user, when I try to commit my work with
git commit -a -v
and I enter a commit message in my editor, I close the file, and g
When you set an editor in the configuration of Git, make sure to pass the parameter "-w" to force Git to wait your commit message that you would type on your custom editor.
git config --global core.editor "[your editor] -w"
This error can happen if your commit comment is a single line starting with a #
character. For example, I got this error when I ended up with the following in my commit message text editor window:
#122143980 - My commit message was here. The number to the left is a Pivotal Tracker story/ticket number that I was attempting to reference in the commit message.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch [MYBRANCH]
# Your branch is up-to-date with 'origin/[MYBRANCH]'.
#
# Changes to be committed:
# modified: [MYFILE1]
# modified: [MYFILE2]
#
The problem, of course, is that my commit message started with a #
character, so git saw that line as a comment, and consequently saw the commit message as being empty, as it had nothing but comments!
The fix was to start my commit message with a character other than #
.
In my specific case, enclosing the Pivotal ID in square brackets made both git and Pivotal happy:
[#122143980] My commit message here.
First remove old entries of editors:
git config --global --unset-all core.editor
git config --unset-all core.editor
Set your editor:
For Notepad++
git config --global core.editor "Notepad++ -w"
git config core.editor "Notepad++ -w"
For sublime
git config --global core.editor "Notepad++ -w"
git config core.editor "subl -w"
I have configured my atom editor as
git config --global core.editor "atom --wait"
but when I did
git commit
when atom was already launched, it opened a new tab for adding comments, but git wasn't waiting for me to save file and throwed "Aborting" message instantly. When I closed atom and tried to commit one more time, git launched atom and waited for comments to be added.
On windows machine for 'Sublime' editor we can also add the following line in .gitconfig file in the following folder [YOUR DRIVE LETTER]:/users/username/
[core]
editor = '[YOUR DRIVE LETTER]:/Program Files/Sublime Text [YOUR VERSION NUMBER]/sublime_text.exe' --wait
Hope it helps.
To begin with, make sure your git is correctly configured to open some kind of editor prompt (visual studio / sublime / notepad++ / atom etc) in order to proceed further.
.gitconfig
file and found out my editor was missing -w
parametergit config --global core.editor "code -w"
command and rechecked my .gitconfig
file, noticed the -w
was added there correctly.Hope this helps for some other newbie's like myself.