This question already has an answer here:
I want to create a bat script that do the following :
opens git bash
run commands on git bash (ex.
git init
,git add .
, ...)
Context: I am working on an idea, that I will access git-bash through java.
I use Netbeans IDE
You don't have to open git bash at all to execute a sequence of git commands in a script:
Create your bash script as any other script:
Save it as
git-myscript
(no extension) anywhere referenced by your$PATH
or%PATH%
(this works even on Windows)Run it with
git myscript
: it will be executed by the git bash.This work for any file named
git-xxx
: you can call that file as a bash script withgit xxx
.(on Linux, Mac or Windows)