Git 要求输入密码,但不要求输入用户名

Git asking for password, but not for username

我在一个团队中工作,我们的代码使用 bitbucket。我们还有一台用于测试应用程序的实时服务器。团队中的每个人都可以通过 SSH 访问此服务器。要在服务器上发布最新代码,团队成员应通过 SSH 登录并执行 git pull 命令。

但是,当我打开我的 bitbucket 存储库时,它以这种格式显示克隆 URL https://MY-USERNAME@bitbucket.org/MY-TEAM-NAME/REPO-NAME 我用它来克隆回购协议。现在,当我使用 git clone 时,git 使用 MY-USERNAME 并仅要求输入密码。但我希望它也询问用户名,因为团队的另一个成员可能会通过 ssh 进入该服务器并执行 git pull.

看来我用错了 URL,因为里面有我的用户名。我在哪里可以获得没有用户名的通用版本?

只需从 URL 的开头删除 MY-USERNAME@,然后 Git 将要求两者。 HTTP 允许您在 URL 的开头使用 user:pass@host.com 进行身份验证,BitBucket 试图通过为您提供个人 URL 来帮助您节省输入。

使用 BitBucket 的示例应用程序的概念证明:

$ git clone https://newuserme@bitbucket.org/newuserme/bb101repo.git
Cloning into 'bb101repo'...
Password for 'https://newuserme@bitbucket.org':

$ git clone https://bitbucket.org/newuserme/bb101repo.git
Cloning into 'bb101repo'...
Username for 'https://bitbucket.org': someoneelse
Password for 'https://someoneelse@bitbucket.org':