运行"git clone git@remote.git"时,如何提供用户名和密码? [英] How do I provide a username and password when running "git clone git@remote.git"?

查看:89
本文介绍了运行"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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆