2

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?

0

1 Answer 1

4

Pipe it to findstr then check the error level

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

IF %errorlevel%==0 GOTO:EOF

echo Continuing ....

To explain the relationship of findstr and errorlevel http://ss64.com/nt/findstr.html says:

FINDSTR will set %ERRORLEVEL% as follows:

0 (False) a match is found in at least one line of at least one file.
1 (True) if a match is not found in any line of any file, (or if the file is not found at all).
2 Wrong syntax 
An invalid switch will only print an error message in error stream.
Sign up to request clarification or add additional context in comments.

1 Comment

Added text to explain how this works

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.