简体   繁体   English

试图重现错误; 进行 git 获取时需要询问密码

[英]trying to recreate a bug; need to be asked for password when doing a git fetch

I know there are lots of posts about how NOT to be asked for a password when you do a git fetch, but I am trying to recreate a bug that happens when you do get asked for a password when doing a git fetch.我知道有很多关于如何在执行 git 提取时不要求输入密码的帖子,但我正在尝试重新创建一个错误,该错误在执行 git 提取时确实被要求输入密码时发生。 I've tried a few different things with oyxkeychain etc. and somehow I just can't recreate a scenario where I get asked for a password when doing a git fetch with bitbucket and with github, doesn't matter which one.我已经用 oyxkeychain 等尝试了一些不同的东西,但不知何故,我无法重新创建一个场景,即在使用 bitbucket 和 github 进行 git 提取时,我被要求输入密码,无论哪个。 Any ideas?有任何想法吗?

Use the following shell commands:使用以下 shell 命令:

git init
git remote add origin 'https://nobody@github.com/doot/repo.git'
git fetch origin

It should then ask you for a password.然后它应该要求您输入密码。

Explanation解释

If your remote URL starts with HTTPS, git uses your.netrc file ( ~/.netrc ) for login credentials.如果您的远程 URL 以 HTTPS 开头,则 git 使用您的 .netrc 文件 ( ~/.netrc ) 作为登录凭据。 For example, this entry will allow me to push to codeberg.org over HTTPS:例如,此条目将允许我通过 HTTPS 推送到 codeberg.org:

machine codeberg.org
 login h3xx
 password 0123456789abcdef0123456789abcdef12345678

If the username/password combo is rejected, it'll ask for both username and password.如果用户名/密码组合被拒绝,它会询问用户名和密码。

If you specify the username in the remote URL, eg https://user@codeberg.org/my-repo.git , it'll only ask for the password.如果您在远程 URL 中指定用户名,例如https://user@codeberg.org/my-repo.git ,它只会询问密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM