"Commit failed - exit code 1 received" when trying to commit a new local reprository in gihub desktop
Asked Answered
L

6

17

when I am trying to commit my new local repository at GitHub from GitHub-desktop it is throwing an error "Commit failed - exit code 1 received"

Longsome answered 26/4, 2018 at 21:31 Comment(0)
D
25

Regarding:

https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfjaFf0XC2nZ7-ocVI0bRywWRfQcFyQcC2jaRA/assets/1711576/26461047/58a465c6-4184-11e7-9ed4-baac5cde302e.png

Check first if you have added files to your index.
Open the command line and check your git status.

Second, see desktop/desktop issue 3701:

some users have run into this error due to having nested .git directories.
Can you try searching your repository to see if you have multiple .git directories?

Had a .git in my repository (which I needed) and a .git in a subfolder (which I deleted), then it worked.

Finally, check if you have any submodule (a .gitmodules file at the root of your repo).
See desktop/desktop issue 1770.

If I commit changes in submodule myself than GitHub Desktop is able to push and/or commit changes after that. After submodule is committed manually SHA1 changes from dirty. At this point I can commit to main repo.

Dean answered 27/4, 2018 at 4:54 Comment(1)
I am using nuxt.js inside Django. As a result, there were two .git folders. One for Django and another for Nuxt.js. I deleted the one for Nuxt.js. Now it works. Thanks.Grater
V
5

I removed the repository from GitHub Desktop (not from the disk) and then added it again as a local repository and this solved the issue for me.

I was receiving this error as well, but unlike others I did not have have any nested .git folders. When trying to view changes, each of the files appeared as "empty" until I removed the repository from GitHub Desktop and added it again.

Vishinsky answered 2/7, 2018 at 19:5 Comment(1)
Worked for me! Thank you!Gayn
P
4

I encountered the same thing and it's caused by .git in subfolder.

Just removed all related .git files and the error disappeared.

Pavo answered 28/3, 2019 at 8:41 Comment(1)
That's right. I added another GitHub Repo to my own Repo. With Windows, the .git folder is normally invisible. You can see and delete him when you change the appearance of invisible folders.Jetliner
M
1

exitcode 1 while committing is not always a real "error".

i do not know GitHub-desktop (and which commands exactly be executed by GitHub-desktop) but maybe your problem has the same core-"problem" as my problem some days ago. in my case i had a branch master which tracks/follows origin/master. i executed:

git pull --no-commit --no-ff
git commit -m "merge"

i found that if origin/master has no commits which can be pulled by the git pull-command then the git commit-command is obviously doing nothing because there are no staged changes and has (imo: surprisingly) the exit-code 1 although no error occurred.

(i guess git commit should have exitcode 0 if it has really created a commit).

Monastic answered 1/1, 2019 at 22:12 Comment(0)
L
0

Resolved. I committed via cmd prompt and did not face this issue again.

Langobard answered 1/8, 2019 at 6:13 Comment(0)
N
0

For the Github desktop,click on the plus sign on the left-hand side of your Github desktop and then select 'Discard .git' files.

Nihhi answered 25/6, 2022 at 22:21 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Bonnett

© 2022 - 2024 — McMap. All rights reserved.