具有不同用户名/帐户的 git clone
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39644366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git clone with different username/account
提问by David Callanan
This is a stupid question, but I've looked it up for ages, and I can't find anything, so I have to ask it.
这是一个愚蠢的问题,但我已经查了很多年了,我找不到任何东西,所以我不得不问它。
How do you clone
something on git
with a different account?
你怎么clone
上的东西git
用不同的帐户?
e.g if I am logged in to abcdef
, and I want to clone something on the account 12345
, how do I do so?
例如,如果我已登录abcdef
,并且想克隆帐户上的某些内容12345
,我该怎么做?
I remember doing this before like this: git clone url -l username
.
Then it would ask me for a password
and I would type it in.
But this either does not work anymore, or my brain is messing with me!
之前这样我记得这样做:git clone url -l username
。然后它会问我一个password
,我会输入它。但这要么不再起作用,要么我的大脑在搞乱我!
Thanks for the help.
谢谢您的帮助。
回答by DirkH
If you clone via https you can do something like
如果您通过 https 进行克隆,则可以执行以下操作
git clone https://[email protected]/username/repository.git
This will prompt you for a password.
这将提示您输入密码。
You can also directly provide a password by calling
您也可以通过调用直接提供密码
git clone https://username:[email protected]/username/repository.git
But be aware that the password will be saved in .git/config and your bash history in that case which is not safe. If you don't like to enter the password every time you should consider cloning via ssh.
但请注意,在这种情况下,密码将保存在 .git/config 和您的 bash 历史记录中,这是不安全的。如果您不想每次都输入密码,则应考虑通过 ssh 进行克隆。