Git Scripts Commands in Windows

I have several git commands that I would like to automate in a restrictive Windows environment. I run these same commands over and over again by executing the git Bash command.

$ 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 understand JScript and I know that it works in my restrictive Windows environment, so I want to start my day by opening a command prompt and typing

 cscript.exe "MyGitRefreshScript.wsf" "MyBranch" "MyOtherBranch" 

And then on demand, for the rest of the day, I can do this, and also use

 cscript.exe "MyGitCommitScript.wsf" "MyBranch" "My commit comments" 

Then I can sit there happily with a command prompt, pressing the up arrow and starting it all day when I do my work.

I cannot install third-party applications or tools on my machine, so I just want to use JScript inside the .wsf file to execute this. I would also like to see the output messages, as I do when I execute commands in git Bash, as now.

Sort of:

 <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 it possible, and if so, how? Is there a clear alternative that is not related to installing third-party tools?

thanks

+5
source share
2 answers

Is there a clear alternative that is not related to installing third-party tools?

Yes, git uses the bash shell, which you can use in git alias or in a git script.

Even in windows you can specify the file name git -xxx, it will have a shell script (which will be interpreted by bash from git).
The shebang of this script (again, even on Windows) will be #!/bin/bash .

In this script you can use git commands and use shell options ( $1 , $2 , ...).

+3
source

Check this -

http://nixkb.org/2014/08/git-made-easy-command-line-scripts-to-manage-git-changes-from-linux/

Here are two scripts that you can run in any Linux box where git is configured for your local repositories.

1) Initialize git or call gitInit.sh

2) Merge changes in git or call gitMerge.sh

0
source

Source: https://habr.com/ru/post/1209413/


All Articles