Alvin Bakker Alvin Bakker - 21 days ago 8
Git Question

Catch response in Windows batch file

I am making a small batch file to pull from git. I use the following:

call git pull origin master


But would like the rest of the batch file to stop running when the response of the command is
Already up-to-date.


How do I do that?

Answer

Pipe it to findstr then check the error level

git pull | findstr /C:"Already up-to-date"

IF %errorlevel%==0 GOTO:EOF

echo Continuing ....