如何在Windows bat脚本中编写git命令? [英] How to script git commands in a Windows bat script?

查看:1446
本文介绍了如何在Windows bat脚本中编写git命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个bat脚本来执行以下操作:


  • 打开git bash

  • > git add。,...)


我正在研究一个想法,我将通过java访问git-bash。

我使用Netbeans IDE

解析方案

p>您不必打开git bash 就可以在脚本中执行一系列git命令:



以任何其他脚本创建您的bash脚本: $!
$ b

 #!/ bin / bash 
git ...
#其他命令

将其另存为 git-myscript (无扩展名)引用您的 $ PATH %PATH%(即使在Windows上也是如此)
$ b

使用 git myscript 运行它:它会被执行由git bash。



对于任何名为 git-xxx 的文件,您可以使用 git xxx作为bash脚本调用该文件

(在Linux,Mac或Windows上)


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:

#!/bin/bash
git ...
#other commands

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 with git xxx.
(on Linux, Mac or Windows)

这篇关于如何在Windows bat脚本中编写git命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆