git push 故障排除 - 它要求用户/通行证

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5813726/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:48:20  来源:igfitidea点击:

Troubleshooting git push - it asks for a user/pass

gitgithub

提问by ripper234

I'm using git on a new git linux computer. When I do git push, it me asks for user/password.

我在一台新的 git linux 计算机上使用 git。当我这样做时git push,我要求输入用户/密码。

I've setup git properly, and in fact cloning the repo from github into a new folder works perfectly (using my public key, not the readonly copy). When I try to push from a previous clone I made to the same repo I get prompted for a user/pass.

我已经正确设置了 git,实际上将 repo 从 github 克隆到一个新文件夹中效果很好(使用我的公钥,而不是只读副本)。当我尝试从之前的克隆推送到同一个 repo 时,我会被提示输入用户/密码。

Of course sshing into [email protected] works, and I made sure my public key is configured in github. Any ideas how to continue debugging?

当然 sshing 到 [email protected] 是有效的,而且我确保我的公钥是在 github 中配置的。任何想法如何继续调试?

采纳答案by manojlds

What do you mean by previous repo? Check the url of the origin from the previous repo's .git/configfile. If you had cloned using http, it will ask for user/pass.

你之前的回购是什么意思?从上一个 repo 的.git/config文件中检查源的 url 。如果您使用 http 进行克隆,它会要求输入用户/密码。

回答by mihaicc

this occurs because you did

这是因为你做了

git clone https://github.com/username/repo

instead of

代替

git clone [email protected]:username/repo.git

回答by Guy

Try the following:

请尝试以下操作:

git remote set-url origin [your git url, such as [email protected]:.../project.git]

git remote set-url origin [你的git url,比如[email protected]:.../project.git]

回答by Prakash

if your repo Url is: https://github.com/abc/xyz.git

如果您的回购网址是: https://github.com/abc/xyz.git

set url from command line as: git remote set-url origin [email protected]:abc/xyz.git

从命令行设置 url 为: git remote set-url origin [email protected]:abc/xyz.git

Replace https://github.com/with [email protected]:

替换 https://github.com/[email protected]:

回答by Amod

May be this will help someone like me.

可能这会帮助像我这样的人。

Please find Git official article for caching your password

请查找 Git 官方文章以缓存您的密码

enter image description here

在此处输入图片说明

Link: https://help.github.com/en/articles/caching-your-github-password-in-git

链接:https: //help.github.com/en/articles/caching-your-github-password-in-git

Commands:

命令:

  1. Set Git to use the credential memory cache

    > git config --global credential.helper cache

  2. Change default cache timeout

    > git config --global credential.helper 'cache --timeout=3600'

  1. 设置 Git 以使用凭证内存缓存

    > git config --global credential.helper cache

  2. 更改默认缓存超时

    > git config --global credential.helper 'cache --timeout=3600'

回答by Joonho Park

In my experience, there are three cases

根据我的经验,有三种情况

1. git remote set-url github(remote repo name) https://github.com/id/a.git
    it asks ID/Passwd
2. git remote set-url github https://[email protected]/id/a.git
    it only asks Passwd
3. git remote set-url github git://github.com:id/a.git
    if you don't have a permission, it complains. So I can't use this for public server of github

all the commands are written to ".git/config"

所有命令都写入“.git/config”

回答by Hassek

for mac If you have git 1.7.10+ it needs to use credential-osxkeychain for password caching. Here is a nice explanation:

对于 mac 如果你有 git 1.7.10+ 它需要使用 credential-osxkeychain 进行密码缓存。这是一个很好的解释:

https://help.github.com/articles/set-up-git

https://help.github.com/articles/set-up-git