使用登录凭据克隆Bitbucket存储库

6
我有一个基本的git克隆命令要将代码克隆到bitbucket,其中我需要添加登录凭据,那么是否可以在bitbucket git克隆命令中添加登录凭据呢?
https://myacc@bitbucket.org/myacc/app.git

像这样的内容吗?

(注:本文已翻译成中文)
https://myacc@bitbucket.org/myacc/app.git -Password "123"

https://stackoverflow.com/search?q=%5Bgit%5D+credentials+in+URL - phd
1个回答

13
你可以使用:
git clone https://user:password@bitbucket.org/myacc/app.git

但这样会在.git/config中的源URL中保存您的凭据。
为了避免这种情况,您可以事后更改源URL
git remote set-url origin https://myacc@bitbucket.org/myacc/app.git


如果我像这样开始,需要在git remove命令中添加项目名称吗? git clone https://user:password@bitbucket.org/myacc/app.git MyApp 那么应该是这样的吗? git remote set-url origin https://myacc@bitbucket.org/myacc/app.git MyApp - Jon not doe xx
它应该按照我发布的方式工作。项目应该已经包含在URL中。 - ColdIV
好的,谢谢,它似乎可以工作,你能进一步解释一下吗?我不明白为什么这是一个问题,“但这将在.git/config中的原始URL中保存您的凭据。” - Jon not doe xx
它不必成为问题。<br/>在你的项目本地.git文件夹中有一个配置文件,任何可以访问这个文件的人都将拥有你的凭据,因为它会在其中存储origin URL。但是如果你是唯一一个能够访问此文件的PC用户,那么就没有问题。 - ColdIV
1
如果密码包含 @ 字符怎么办? - Marinos An
3
您可以将@替换为%40。更多信息请参见:https://fabianlee.org/2016/09/07/git-calling-git-clone-using-password-with-special-character/ - Genki

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接