0

I have a batch file where I want to use the command git pull

Sometimes the git command might fail from different reasons (The one that I discovered was that it had modified files)

However using the %ERRORLEVEL% or !ERRORLEVEL! do not work at all

git pull

IF %ERRORLEVEL% NEQ 0 (
   ECHO restoring source code returned %ERRORLEVEL%
   EXIT /B 1
   GOTO:EOF
)

How can I determine that the command git pull has failed?

Dan
  • 683
  • 2
  • 8
  • 24
  • `git` doesn't, and never has, returned consistent, or useful, exit codes! Your best advice would be to look for a unique indicator in the stream and pipe that through `find.exe` or `findstr.exe` to identify a success or failure. – Compo Jul 12 '23 at 08:25
  • 1
    It this [advise](https://stackoverflow.com/questions/63754134/) helpful? – Daemon-5 Jul 12 '23 at 08:26
  • @Daemon-5 It might help. I will try to use git fetch and git merge and maybe they provide the correct exit code – Dan Jul 12 '23 at 08:37
  • @Daemon-5 write the answer that pull should be split into fetch and merge in order to get the errorlevelcode so you can gain the points – Dan Jul 12 '23 at 09:35

0 Answers0