首页 > 解决方案 > 如何在推送命令期间提供 git 凭据?

问题描述

我正在使用 windows powershell 创建一个自动化脚本,该脚本将克隆一个 repo,对其进行一些操作,然后最终推送它。

到目前为止,这是我的代码:

git clone <github-domain>.com/org/repo

cd org/

echo "new content" >> newfile.txt

git add .

git commit -m "added new content"

git push origin master # here I receive a pop up asking me for my username and password

我想知道是否可以在push命令期间传递用户名和密码,因为这应该是完全自动化的。

就像是:

git push origin master --username a --password b

我尝试在网上查找,但所有来源都指向 ssh,并且没有“自动”的方式来做到这一点。

标签: git

解决方案


使用git-credential-store

只有第一次,您需要输入密码 请按照以下步骤操作:

git config credential.helper store
git push origin master
# supply username and Password for the 1st time

现在下次他们不要求用户名或密码

谢谢!


推荐阅读