I'm not sure if this is true for all Windows git packages, but at least some use a
git.cmd script as a wrapper around the actual git executables (for example
git.exe). So when you're batch file uses a
git command, Windows is actually running another batch file.
Unfortunately, when one batch file invokes another, by default it 'jumps' to the invoked batch file, never to return (this is for compatibility with ancient MS-DOS command processors or something).
You can solve this problem in a couple ways:
gitin your batch files using the
callcommand to run the
git.cmdbatch file and return back to yours:
call git checkout %2 call git fetch origin rem etc...
gitin your batch file using the
.exeextension explicitly to avoid the
git.cmdbatch file altogether. For this to work, you might need to make sure that you have your path and other environment variables set the way
git.exeexpects (that seems to be what
git.cmddoes in msysgit):
git.exe checkout %2 rem etc...