Does git return specific return error codes?

Like merge errors or reinstallation errors. Does it have a unique error code?

+76
git
Feb 07
source share
4 answers

I set the test to fail. This is what I got:

$ git merge newbranch Auto-merging test.txt CONFLICT (content): Merge conflict in test.txt Automatic merge failed; fix conflicts and then commit the result. $ echo $? 1 

Git returns 0 when it merges correctly, as expected.

+46
Feb 07 '11 at 4:08
source share

In short, no. You will see exit code 1 for errors and 0 for success.

With a quick grepping source, some of the expected 127 and 128 are for their specific purposes (command not found, errors already reported) and some unusual codes in several places, but to start the mill error, all exit(1) .

+52
Feb 07 2018-11-11T00:
source share

Running git status in a non-git repository returns 128, not 1, which is useful when quickly determining whether or not a git repository exists.

+12
Oct 18 '13 at 4:49 on
source share

Error 128, without error message from git, may be a problem for the "unexpected problem".

I got this from operations that needed to change files under .git (for example, " git checkout -- myfile " to return the changed file) by another user. (In my case, " chmod -R og+w .git " fixed this, of course, do not do this if you do not understand the security implications for your case!)

+5
Nov 09 '11 at 3:21
source share



All Articles