git的承诺,并通过在Windows批处理文件推 [英] git commit and push via batch file on Windows
问题描述
我做同样的任务经常犯,推动修改远程分支的。懒惰有时候,我需要把设置Git命令来自动执行这些步骤:
I do same task often of committing and pushing changes to remote branch. Being lazy sometimes, I needed to put set of git commands to automatically perform these steps:
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
一切工作excpet的最后推
命令。这里是输出:
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 . . .
正如你可以看到,推
,我得到:
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壳本身的命令,一切工作正常。我还增加了混帐到Windows PATH环境变量。
When I run above commands via git shell itself, everything works fine. I have also added git to Windows Path env variables.
有没有人有,为什么它的工作原理上的git壳的想法,而不是批处理命令? (即使其他命令的工作,但并不推
)
Does anyone have an idea of why it works on git shell and not on batch command ? (even though other commands work but not push
)
推荐答案
对于我来说,默认情况下Windows执行 .SH
文件正确使用Git猛砸。所以,我会写你的脚本作为一个普通的bash shell脚本:
For me, by default, Windows executes .sh
files correctly using Git Bash. So I would write your script as a regular bash shell script:
#!/bin/sh
cd /d/wamp/www/projectName
git checkout dev
git add .
git commit -am "made changes"
git push
echo Press Enter...
read
这篇关于git的承诺,并通过在Windows批处理文件推的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!