Dev*_*v01 14 windows git batch-file
我经常做同样的任务,即将更改提交到远程分支.有时懒惰,我需要放置一组git命令来自动执行这些步骤:
cd D:\wamp\www\projectName
git checkout dev
git add .
git commit -am "made changes"
git push
pause
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
cd D:\wamp\www\projectName
call git checkout dev
call git add .
call git commit -am "made changes"
call git push
pause
Run Code Online (Sandbox Code Playgroud)
和
cd D:\wamp\www\projectName
git.exe checkout dev
git.exe add .
git.exe commit -am "made changes"
git.exe push
pause
Run Code Online (Sandbox Code Playgroud)
最终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 . . .
Run Code Online (Sandbox Code Playgroud)
如你所见,因为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.
Run Code Online (Sandbox Code Playgroud)
当我通过git shell本身运行上面的命令时,一切正常.我还在Windows Path env变量中添加了git.
有没有人知道为什么它适用于git shell而不是批处理命令?(即使其他命令工作但没有push)
Sto*_*ica 27
对我来说,默认情况下,Windows .sh使用Git Bash正确执行文件.所以我会把你的脚本编写为常规的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
Run Code Online (Sandbox Code Playgroud)