运行“git clone git@remote.git"时如何提供用户名和密码? [英] How do I provide a username and password when running "git clone git@remote.git"?
本文介绍了运行“git clone git@remote.git"时如何提供用户名和密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何为这样的 HTTPS 请求提供用户名和密码:
I know how to provide a username and password to an HTTPS request like this:
git clone https://username:password@remote
但我想知道如何像这样向遥控器提供用户名和密码:
But I'd like to know how to provide a username and password to the remote like this:
git clone git@remote.git
我试过这样:
git clone username:password@git@remote.git
git clone git@username:password@remote.git
git clone git@remote.git@username:password
但他们没有工作.
推荐答案
基于 Michael Scharf 的评论:
Based on Michael Scharf's comment:
你可以省略密码,这样它就不会被记录到你的 Bash 历史文件中:
You can leave out the password so that it won't be logged in your Bash history file:
git clone https://username@github.com/username/repository.git
它会提示您输入密码.
或者,您可以使用:
git clone https://username:password@github.com/username/repository.git
这种方式在 GitHub 存储库中对我有用.
This way worked for me from a GitHub repository.
这篇关于运行“git clone git@remote.git"时如何提供用户名和密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文