gpt4 book ai didi

windows - git 在 Windows 上通过批处理文件提交和推送

转载 作者:IT王子 更新时间:2023-10-29 00:35:39 26 4
gpt4 key购买 nike

我经常执行相同的任务,将更改提交并推送到远程分支。有时很懒,我需要设置一组 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 本身运行上述命令时,一切正常。我还将 git 添加到 Windows 路径环境变量中。

有谁知道为什么它适用于 git shell 而不是批处理命令? (即使其他命令有效但 push 无效)

最佳答案

对我来说,默认情况下,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

关于windows - git 在 Windows 上通过批处理文件提交和推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20397800/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com