git提交并通过Windows上的batch file推送

我经常做同样的任务,将改变提交给远程分支。 有时懒,我需要把一套git命令自动执行这些步骤:

cd D:\wamp\www\projectName git checkout dev git add . git commit -am "made changes" git push pause 

我也试过:

 cd D:\wamp\www\projectName call git checkout dev call git add . call git commit -am "made changes" call git push pause 

 cd D:\wamp\www\projectName git.exe checkout dev git.exe add . git.exe commit -am "made changes" git.exe push pause 

一切正常工作最后的push命令。 这里是输出:

 D:\wamp\www\givingcircle>git checkout dev Already on 'dev' Your branch is ahead of 'origin/dev' by 1 commit. D:\wamp\www\givingcircle>git add . D:\wamp\www\givingcircle>git commit -am "made changes" # On branch dev # Your branch is ahead of 'origin/dev' by 1 commit. # nothing to commit, working directory clean D:\wamp\www\givingcircle>git push Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. D:\wamp\www\givingcircle>pause Press any key to continue . . . 

正如你所看到的,为了push ,我得到了:

 D:\wamp\www\givingcircle>git push Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 

当我通过git shell本身运行上述命令时,一切正常。 我也已经添加到Windowspath环境variables的git。

有没有人有一个想法,为什么它在git shell而不是批处理命令? (即使其他命令工作,但不push

Solutions Collecting From Web of "git提交并通过Windows上的batch file推送"

对我来说,默认情况下,Windows使用Git Bash正确执行.sh文件。 所以我会写你的脚本作为一个常规的bash shell脚本:

 #!/bin/sh cd /d/wamp/www/projectName git checkout dev git add . git commit -am "made changes" git push echo Press Enter... read 

试试这个!

 cd c://TESTS/path set HOME=%USERPROFILE% GIT COMMAND GOES HERE pause