0

I use this Windows command to open Git Bash:

start "" "%SYSTEMDRIVE%\Program Files (x86)\Git\bin\sh.exe" --login 
start "" "%SYSTEMDRIVE%\Program Files\Git\bin\sh.exe" --login

I want to run a script from Git Bash now.
How can I do to run a script from Windows command on Git Bash?

I want that Git Bash run git ex (a script from me) when it is open.

1 Answer 1

4

You don't need to call bash or sh to run a bash script from DOS.

Simply write your bash script in a file called git-xxx (replace xxx by something more expressive) (no extension).

Then, from your DOS (provided your %PATH% include <git>/bin), call:

git xxx

That will launch the git-xxx script (it needs to be somewhere in your PATH too), through the git bash.exe session.

Sign up to request clarification or add additional context in comments.

2 Comments

This doesn't work for me. Is this still a feature in recent versions of git?
@jkokorian No, it is a known feature for quite some time now. But your git-xxx needs to be in your %PATH%.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.