Aborting commit due to empty commit message error could not commit staged changes

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 get this error: Aborting commit due to empty commit mess...

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 get this error:

Aborting commit due to empty commit message.

I have read nearly all the topics addressing to this issue, changed editors, basically tried everything but nothing helps. What should I do?

One thing I noticed, while trying the whole process with notepad++, the file couldn’t be saved.

A possible workaround is this:

git commit -am "SomeComment"

But by doing so I feel I am kind of nullifying the purpose of using git. I want to properly document my changes.

Jon Schneider's user avatar

Jon Schneider

24.9k21 gold badges144 silver badges167 bronze badges

asked Mar 15, 2012 at 17:39

cngkaygusuz's user avatar

6

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"

answered Jul 28, 2012 at 16:24

Zakaria AMARIFI's user avatar

Zakaria AMARIFIZakaria AMARIFI

1,6911 gold badge10 silver badges2 bronze badges

12

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. 

answered Oct 13, 2016 at 15:12

Jon Schneider's user avatar

Jon SchneiderJon Schneider

24.9k21 gold badges144 silver badges167 bronze badges

4

For Visual studio Code

git config --global core.editor "code -w"

For atom

git config --global core.editor "atom -w"

For sublime

git config --global core.editor "subl -w"

answered Jul 7, 2015 at 19:06

Armin's user avatar

ArminArmin

2813 silver badges6 bronze badges

3

I’m also a newbie in Git. I encountered basically the same problem as yours. I solved this by typing:

git commit -a -m 'some message'

The reason is that git doesn’t allow commit without messages. You have to associate some messages with your commit command.

answered Nov 11, 2013 at 9:41

Nothing More's user avatar

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"
    

answered Aug 17, 2016 at 21:18

fizcris's user avatar

fizcrisfizcris

4272 gold badges6 silver badges13 bronze badges

If you want to commit with a proper (long, multi-line comment) documentation, but don’t want the -m option, what you can do (and that I do when preparing my commits) is to:

  • write your documentation (while you are making the changes) in a separate file ‘doc-commit’ (or whatever name you want to call it)
  • commit with a ‘git commit -a -F /path/to/doc-commit‘)

In short, use a separate file (which can be at any path you want) as your commit message.

answered Mar 16, 2012 at 7:14

VonC's user avatar

VonCVonC

1.2m508 gold badges4248 silver badges5069 bronze badges

3

I was having this problem. I just installed 1.8.0 earlier, and I found I had to modify the above slightly. I’m very much new at all of this, but essentially it seems that, when committing, it’ll use content.editor, not core.editor, at least if you have something set for content.editor.

So, it was

git config --global content.editor "pico -w"

that finally let me commit!
Obviously, of course, use whatever editor you use.

Hope this helps somebody someday!

answered Nov 13, 2012 at 22:49

salix's user avatar

salixsalix

611 silver badge1 bronze badge

1

The git does not allows commit without message specified. Have you specified the commit message in commit dialog?

Note that the lines starting with # are treated as comment by Git and are not considered as comments and ignored by Git.

Andrew Barber's user avatar

Andrew Barber

39.2k20 gold badges93 silver badges122 bronze badges

answered Nov 28, 2012 at 16:34

Yin's user avatar

YinYin

491 silver badge1 bronze badge

0

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.

answered Nov 27, 2015 at 15:15

Pavel Tsybulivskyi's user avatar

1

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.

Max Leske's user avatar

Max Leske

4,9776 gold badges46 silver badges53 bronze badges

answered Feb 21, 2013 at 17:22

Anmol Saraf's user avatar

Anmol SarafAnmol Saraf

14.7k10 gold badges50 silver badges60 bronze badges

1

git config --global core.editor "subl -w" -F 

This helped me after lots and lots of trial and error, hope someone finds it useful.

I had already symlinked sublime 3 to use as subl command.

I am completely clueless, for why -F flag outside the » » worked.

answered Jun 4, 2020 at 20:17

Naman Sharma's user avatar

1

It expects a commit message.

For vim: ( I’m a newbie as well. I only worked with vim so far)

After your command,

git commit -v

You will be directed to a file with the name

«.git/COMMIT_EDITMSG»

That opens up in your editor (which in my case is vim)

You will find a lot of commented text that looks exactly like what you saw when you did

git status  OR
git diff

If you notice, you can see an empty line on top — where it expects a commit message.
You may type the commit message here and save & quit the editor. It’s done!

answered Aug 23, 2019 at 2:20

AshlinJP's user avatar

AshlinJPAshlinJP

3631 silver badge10 bronze badges

1

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.

  • For my case I configured my git to use visual studio in Ubuntu environment.
  • I tried committing a change, it failed with given failure.
  • Then I looked at my .gitconfig file and found out my editor was missing -w parameter
  • I ran git config --global core.editor "code -w" command and rechecked my .gitconfig file, noticed the -w was added there correctly.
  • Tried committing the change again and it worked for me.

Hope this helps for some other newbie’s like myself.

answered Oct 22, 2019 at 21:23

User1990's user avatar

Make sure to sure a capital W.

git config —global core.editor «open -a ‘Sublime Text 2’ -W»

or use the following command to replace an existing one that isn’t working properly.

git config —replace-all core.editor «open -a ‘Sublime Text 2’ -W»

answered Jul 1, 2015 at 16:45

bradley4's user avatar

bradley4bradley4

3,6936 gold badges33 silver badges41 bronze badges

For commenting on Notepad++ (Windows) do this:

1. Create a batch file somewhere (e.g. c:Usersmescriptsnpp.bat)
Write this in the batch file (depending on where your Notepad++ is installed):

"C:Program FilesNotepad++notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"

2. Save the batch file.
3. Open .gitconfig (which is usually in your Windows User folder) and make sure that
under [core] section you have:

editor = '"c:\Users\me\scripts\npp.bat"'

Or either run:

git config --global core.editor '"c:Usersmescriptsnpp.bat"'

4. Now perform commit of some kind, and it will open Notepad++, git commit will now wait until notepad++ window is closed.

answered Jun 28, 2015 at 16:44

Mercury's user avatar

MercuryMercury

6,8452 gold badges40 silver badges51 bronze badges

I had the same problem with atom but I resolved it by using notepad instead by changing the core editor for git using the following command

git config --global core.editor "C:\Windows\notepad.exe"

answered Apr 15, 2021 at 11:21

Abey Bruck's user avatar

Abey BruckAbey Bruck

3283 silver badges5 bronze badges

I fixed the problem by switching from my fancy MacVim editor which opens a new window, to the standard default vim in /user/bin/vim which opens in the same window as the shell from whence it is called, and that seems to have fixed the problem.

answered Jun 29, 2015 at 18:38

slehar's user avatar

sleharslehar

3113 silver badges6 bronze badges

1

I got this problem, and found out that if I dont put any comment after committing, it gives me that error. If I jump to get back to the main bash straight away, it doesnt commit.Just to be more clear, Im using GIT Bash, not other editor

answered Apr 13, 2018 at 3:38

When I used the complete atom filepath it didn’t work, so instead of using:

git config --global core.editor "c:/programs/atom/atom.exe -w"

I used:

git config --global core.editor "atom -w"

and it worked just fine. Good luck!

IMPORTANT: First make sure that atom starts correctly calling it directly (atom) from the command line you are using.

answered Sep 23, 2018 at 18:20

Juan Castellon's user avatar

solution for commit error

enter image description here

As I shown above there is a commit field which you need to enter while committing, this is basically for version control and understanding the changes for each commit.

If you don’t enter this you will get the error :Aborting commit due to empty commit message

Note: the above works only in Rstudio commit and pulling the files.

Kalana's user avatar

Kalana

5,4557 gold badges29 silver badges51 bronze badges

answered Dec 29, 2019 at 7:18

Sanjay KV's user avatar

I got this error, and even though i used git config --global core.editor "code -w", it still wouldn’t wait for me to close the file. It would just abort instantly.

My problem was that I had run this command earlier git config core.editor "code".

It seems that core.editor (which I presume is a local working directory specification), took precedence over --global core.editor.

If git config --global core.editor "code -w" (or whatever editor you are trying to use) does not work for you, try omitting the --global.

answered Sep 10, 2020 at 13:48

Flux's user avatar

FluxFlux

4145 silver badges17 bronze badges

The reason for your problem is your editor was closed before you enter the commit. I faced the same issue. So telling your editor to wait is the answer for your problem.

You need to change the global variable of core.editor in GIT for that.

Before changing you might wanna see, what is the existing one.
Then use below code to see them as a list.

git config --global --list

mine, before core.editor is with no waiting.

core.editor=gedit

Therefore I changed that variable with below two codes. First line for unset the variable and second for declaring it correctly.

git config --global --unset-all core.editor

git config --global core.editor "code -w"

With this, my issue was solved, Hope yours too. If you check the global variables with

git config --global --list

again, you will see your core.editor is changed too, like below.

core.editor=gedit -w

It shows now your «waiting» function is working.

answered Feb 25, 2021 at 0:39

shalitha anuradha's user avatar

I have just encountered this error and just solved it, so I would like to share my scenario and answer as well.

I ran the command
git config --global core.editor ""C:Program Files (x86)Notepad++notepad++.exe""

and then when I do git commit it opens the notepad++ but after I give my commit message and saves by pressing «ctrl+s», it has shown me this message in command prompt -> «Aborting commit due to empty commit message.» (as shown in the below image)

git commit showing error - abort commit due to empty message

I solved it by providing my commit message like below (we need to provide 2 empty lines between our Commit TITLE and commit Description as shown below)

Note: The lines started with «#» are automatically generated by git.

git commit opens editor which can be set by the command git config --global core.editor ""C:Program Files (x86)Notepad++notepad++.exe""

answered Mar 30, 2021 at 12:17

Jagadeesh's user avatar

JagadeeshJagadeesh

1012 silver badges7 bronze badges

After wasting one hour to make it work on my Ubuntu, I decided to use Sublime Text instead of Atom to write my commit messages.
So instead of:

git config --global core.editor "atom -w"

I used the same command for Sublime.

git config --global core.editor "subl -w"

And it worked fine.
Sublime pause waiting for the commit message.

answered Jul 23, 2021 at 13:21

Davide Casiraghi's user avatar

Davide CasiraghiDavide Casiraghi

13.4k8 gold badges31 silver badges53 bronze badges

-w as others suggested didn’t work for me but --wait did.

Full input is git config --global core.editor 'code --wait'

(code is VS Code, replace with subl for Sublime etc.)

As the full name of the argument makes it obvious, this sets editor for commit message to open (code) and tells it to wait until file is saved and closed.

Don’t forget to save the file before closing.

answered Aug 30, 2021 at 17:47

n-smits's user avatar

n-smitsn-smits

6676 silver badges20 bronze badges

Hello Steve,

Thanks for your reply,

Yes, the commit worked many times well on this same machine,

Here is the result oft he show origin command:

raoul.gendroz@INT-NB027 MINGW64 ~
$ git config —list —show-origin
file:C:/Program Files/Git/etc/gitconfig diff.astextplain.textconv=astextplain
file:C:/Program Files/Git/etc/gitconfig filter.lfs.clean=git-lfs clean — %f
file:C:/Program Files/Git/etc/gitconfig filter.lfs.smudge=git-lfs smudge — %f
file:C:/Program Files/Git/etc/gitconfig filter.lfs.process=git-lfs filter-process
file:C:/Program Files/Git/etc/gitconfig filter.lfs.required=true
file:C:/Program Files/Git/etc/gitconfig http.sslbackend=openssl
file:C:/Program Files/Git/etc/gitconfig http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
file:C:/Program Files/Git/etc/gitconfig core.autocrlf=true
file:C:/Program Files/Git/etc/gitconfig core.fscache=true
file:C:/Program Files/Git/etc/gitconfig core.symlinks=false
file:C:/Program Files/Git/etc/gitconfig pull.rebase=false
file:C:/Program Files/Git/etc/gitconfig credential.helper=manager
file:C:/Users/raoul.gendroz/.gitconfig user.name=Raoul Gendroz
file:C:/Users/raoul.gendroz/.gitconfig user.email=#############@############
file:C:/Users/raoul.gendroz/.gitconfig filter.lfs.smudge=git-lfs smudge — %f
file:C:/Users/raoul.gendroz/.gitconfig filter.lfs.process=git-lfs filter-process
file:C:/Users/raoul.gendroz/.gitconfig filter.lfs.required=true
file:C:/Users/raoul.gendroz/.gitconfig filter.lfs.clean=git-lfs clean — %f

Tanks in advance,
Raoul

Как пользователь newbie git, когда я пытаюсь выполнить свою работу с помощью

git commit -a -v

и я ввожу сообщение фиксации в свой редактор, я закрываю файл и получаю эту ошибку:

Aborting commit due to empty commit message.

Я прочитал почти все темы, посвященные этой проблеме, изменил редакторы, в основном пробовал все, но ничего не помогает. Что мне делать?

Одна вещь, которую я заметил, при попытке всего процесса с помощью блокнота ++, файл не мог быть сохранен.

Возможным обходным путем является следующее:

git commit -am "SomeComment"

Но, делая это, я чувствую, что я свожу на нет цель использования git. Я хочу правильно документировать свои изменения.

4b9b3361

Ответ 1

Когда вы устанавливаете редактор в конфигурации Git, обязательно передайте параметр «-w», чтобы заставить Git ждать ваше сообщение фиксации, которое вы наберете в своем настраиваемом редакторе.

git config --global core.editor "[your editor] -w"

Ответ 2

Эта ошибка может произойти, если ваш комментарий коммита — это одна строка, начинающаяся с символа #. Например, я получил эту ошибку, когда в моем текстовом редакторе текстовых сообщений сообщения комментировал следующее:

#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]
#

Проблема, конечно, в том, что мое сообщение commit начиналось с символа #, поэтому git видел эту строку как комментарий и, следовательно, видел сообщение commit как пустое, так как у него было только комментарии!

Исправление должно было начаться с моего сообщения с символом, отличным от #.

В моем конкретном случае включение идентификатора Pivotal в квадратных скобках сделало как git, так и Pivotal счастливым:

[#122143980] My commit message here. 

Ответ 3

Для кода Visual Studio

git config --global core.editor "code -w"

Для атома

git config --global core.editor "atom -w"

Для возвышенного

git config --global core.editor "subl -w"

Ответ 4

Если вы хотите зафиксировать правильную (длинную, многострочную комментариев) документацию, но не хотите использовать параметр -m, что вы можете сделать (и что я делаю при подготовке мои коммиты):

  • напишите свою документацию (при внесении изменений) в отдельный файл ‘doc-commit’ (или любое другое имя, которое вы хотите назвать)
  • совершить с ‘git commit -a -F /path/to/doc-commit‘)

Короче говоря, используйте отдельный файл (который может быть любым желаемым путем) в качестве сообщения о фиксации.

Ответ 5

Я тоже новичок в Git. Я столкнулся с той же проблемой, что и ваша. Я решил это, набрав:

git commit -a -m 'some message'

Причина в том, что git не разрешает фиксацию без сообщений. Вы должны связать некоторые сообщения с вашей командой commit.

Ответ 6

У меня была эта проблема. Я только что установил 1.8.0 раньше, и я обнаружил, что мне пришлось немного модифицировать это. Я очень много нового, но по сути кажется, что при совершении он будет использовать content.editor, а не core.editor, по крайней мере, если у вас есть что-то настроенное для content.editor.

Итак, это было

git config --global content.editor "pico -w"

что, наконец, позвольте мне совершить!
Разумеется, конечно, используйте любой редактор, который вы используете.

Надеюсь, это когда-нибудь поможет кому-нибудь!

Ответ 7

git не разрешает фиксацию без сообщения. Вы указали сообщение фиксации в диалоге фиксации?

Обратите внимание, что строки, начинающиеся С#, обрабатываются как комментарии git и не рассматриваются как комментарии и игнорируются Git.

Ответ 8

На машине Windows для редактора «Sublime» мы также можем добавить следующую строку в файле .gitconfig в следующей папке [ВАШЕ ДИСКОВОЙ ПИСЬМО]:/users/username/

[core]
  editor = '[YOUR DRIVE LETTER]:/Program Files/Sublime Text [YOUR VERSION NUMBER]/sublime_text.exe' --wait

Надеюсь, что это поможет.

Ответ 9

Я сконфигурировал свой атомный редактор как

git config --global core.editor "atom --wait"

но когда я сделал

git commit

когда атом уже был запущен, он открыл новую вкладку для добавления комментариев, но git не ожидал, что я сохраню файл и вытащу сообщение «Отменить» мгновенно. Когда я закрыл атом и попытался совершить еще один раз, git запустил атом и ждал добавления комментариев.

Ответ 10

Сначала удалите старые записи редакторов:

git config --global --unset-all core.editor
git config  --unset-all core.editor

Задайте свой редактор:

  • Для Notepad ++

    git config --global core.editor "Notepad++ -w"
    git config core.editor "Notepad++ -w"
    
  • Для возвышенного

    git config --global core.editor "Notepad++ -w"
    git config core.editor "subl -w"
    

Ответ 11

Для комментариев к Notepad ++ (Windows) выполните следующее:

1. Создайте пакетный файл где-нибудь (например, c:Usersmescriptsnpp.bat)
Запишите это в пакетном файле (в зависимости от того, где установлен ваш Notepad ++):

"C:Program FilesNotepad++notepad++.exe" -multiInst -notabbar -nosession -noPlugin "$*"

2. Сохранить пакетный файл.
3. Откройте .gitconfig(который обычно находится в папке пользователя Windows) и убедитесь, что
в разделе [core]:

editor = '"c:\Users\me\scripts\npp.bat"'

Или запустите:

git config --global core.editor '"c:Usersmescriptsnpp.bat"'

4. Теперь выполните фиксацию какого-либо типа, и он откроет Notepad ++, git commit теперь будет ждать закрытия окна «Блокнот ++».

Ответ 12

Удостоверьтесь, что столица W.

git config —global core.editor «open -a ‘Sublime Text 2’ -W»

или используйте следующую команду, чтобы заменить существующую, которая не работает должным образом.

git config —replace-all core.editor «open -a ‘Sublime Text 2’ -W»

Ответ 13

Ожидается сообщение о коммите.

Для vim: (я тоже новичок. До сих пор я работал только с vim)

После вашей команды,

git commit -v

Вы будете перенаправлены в файл с именем

«.Git/COMMIT_EDITMSG»

Это открывается в вашем редакторе (который в моем случае vim)

Вы найдете много комментариев, которые выглядят точно так же, как вы видели, когда делали

git status  OR
git diff

Если вы заметили, вы можете увидеть пустую строку сверху — там, где ожидается сообщение о коммите.
Вы можете ввести здесь сообщение о коммите и сохранить & выйти из редактора. Это было сделано!

Ответ 14

Я исправил проблему, переключившись с моего любимого редактора MacVim, который открывает новое окно, на стандартный vim vim в /user/bin/vim, который открывается в том же окне, что и оболочка, откуда он вызывается, и это кажется чтобы устранить проблему.

Ответ 15

У меня возникла эта проблема, и я обнаружил, что если я не оставляю комментарий после коммита, это выдает мне эту ошибку. Если я сразу перехожу к главному bash, он не фиксируется. Просто чтобы быть более понятным, я использую GIT Bash, а не другой редактор

Ответ 16

Когда я использовал полный путь к файлу Atom, он не работал, поэтому вместо использования:

git config --global core.editor "c:/programs/atom/atom.exe -w"

Я использовал:

git config --global core.editor "atom -w"

и все работало просто отлично. Удачи!

ВАЖНО: Сначала убедитесь, что atom начинает правильно вызывать его (atom) из командной строки, которую вы используете.

Meg Gutshall

I use Visual Studio Code on my Mac as my text editor and have it set up to open a new window to type my commit message, however when I type ‘git commit’ in the terminal, it instantaneously displays ‘Aborting commit due to empty commit message.’

I have my git config set up as ‘git config —global core.editor «code —wait»‘ and when I type ‘git config —global -e’ it shows ‘[core] editor = code —wait’. I’ve uninstalled and reinstalled git, I’ve went through the VS Code as Git Editor setup guide, and have searched online for a solution for at least ten hours. My git and VS Code versions are up to date and my commits work when I type ‘git commit -m «message here»‘ in the command line, but I still don’t know why my VS Code editor option isn’t working.

Any ideas here? Thank you!

Tired of sifting through your feed?

Find the content you want to see.

Change your feed algorithm by adjusting your experience level and give weights to the tags you follow.

Понравилась статья? Поделить с друзьями: