如何使用指定的用户名/密码执行git操作?

如何使用指定的用户名/密码执行git操作?,git,Git,我想在CI服务器上运行脚本,该服务器将自动从git存储库中删除旧分支。我必须将git的用户名/密码作为参数传递给这个脚本,因为服务器是在不同的团队之间共享的,所以我不能在服务器上存储ssh密钥。我可以使用提供的凭据克隆存储库git clonehttps://username:password@github.com/username/repository.git。 但是我不能执行任何其他操作,例如,git push origin--delete branch_name——promt将请求密码。 在

我想在CI服务器上运行脚本,该服务器将自动从git存储库中删除旧分支。我必须将git的用户名/密码作为参数传递给这个脚本,因为服务器是在不同的团队之间共享的,所以我不能在服务器上存储ssh密钥。我可以使用提供的凭据克隆存储库
git clonehttps://username:password@github.com/username/repository.git
。 但是我不能执行任何其他操作,例如,
git push origin--delete branch_name
——promt将请求密码。
在我的情况下,有没有办法通过脚本为git操作提供凭据?

当您使用以下命令克隆存储库时,提示将永远不会要求输入密码

git clone https://username:password@github.com/username/repository.git
请确保在origin关键字中设置了您的用户名和密码

git remote -v

origin  https://username:password@github.com/username/repository.git (fetch)
origin  https://username:password@github.com/username/repository.git (push)
如果不存在,则尝试更改url

git remote set-url origin https://username:password@github.com/username/repository.git 
之后,它将不会要求输入密码

git push origin --delete branch_name