Running a batch file in git shell


Under Windows 7 I have a batch file for checking the status of some repos and outputting the returns to a file (with standard powershell issued git commands).

This works fine when launched from git shell, my question is how can I do this without launching git shell first?

So I want to be able to enter in a standard prompt or in a runnable batch file a command / commands which will launch a given batch file in git shell.


If you consider what git-cmd.bat does, all you need to do is to set the right variable %PATH% before your git commands in your script:

If you don’t, here is what you would see:

I have uncompressed the latest portable version of msysgit.

Put anywhere a test.bat script (so no powershell involved there) with the following content:

Make sure HOME is correctly set, because Git will look for your global git config there.

The result will give you:

Note: that same script would work perfectly from a powershell session.


Running a batch file in git shell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply