I have a few git commands I would like to automate in a restrictive windows environment. I find myself running these same commands over and over, executing in Git Bash.
$ git cd "R:/my/directory/repo"
$ git pull
$ git checkout "MyBranch"
$ git merge "MyOtherBranch"
and
$ git checkout "MyBranch"
$ git add .
$ git commit -m "My commit comments"
I'm proficient with JScript, and I know it works in my restrictive windows environment, so what I want to do is to start my day by opening the command prompt and typing
cscript.exe "MyGitRefreshScript.wsf" "MyBranch" "MyOtherBranch"
And then on demand, throughout the rest of the day, I can do that, and also use
cscript.exe "MyGitCommitScript.wsf" "MyBranch" "My commit comments"
Then I can sit there happily with the command prompt open pressing the up arrow and run those all day long as I do my work.
I can not install third party applications or tools on my machine, so I am looking to just use JScript inside a .wsf file to accomplish this. I would also like to be able to see the output messages like I do when running the commands in Git Bash as I do now.
Something like:
<job id="main">
<script language="JScript">
var sh = new ActiveXObject("WScript.Shell");
sh.Run(Git.exe "SomeCommand" ?);
//or
var git = new ActiveXObject("Git");
git.SomeCommand ???
...
Is this possible, and if so, how? Is there a clear alternative that doesn't involve some third party tool installation?
Thank you
Is there a clear alternative that doesn't involve some third party tool installation?
Yes, git uses a bash shell which you can use in git alias, or in git script.
Even on windows, you can define a file name git-xxx, with a shell script in it (which will be interpreted by the bash from git).
The shebang of that script (again, even on Windows) will be #!/bin/bash
.
In that script, you can use the git commands, and use the shell parameters ($1
, $2
, ...).