刚刚遇到这个 Git 行为,它看起来像是凭证存储的错误:
$ git pull
Username for 'https://github.com': ...
Password for 'https://...@github.com': ...
Already up-to-date.
$ git config credential.helper store
$ git pull
remote: Repository not found.
然后,去编辑 .git/config 以删除[credential] helper = store和 git pull 再次工作。
什么可能导致它?
如何在不遇到此错误的情况下使用凭证助手?
更新在 Ubuntu 14.04 上使用 git 版本 1.9.1
更新使用 git 版本 2.9.3 重新测试,结果相同。
更新我在 github 上的 ~/.git-credentials 中有几个帐户。我用 GIT_CURL_VERBOSE=1 GIT_TRACE=1 运行 git,它看起来像是按照它们列出的顺序选择第一个 github 帐户。
但是,我正在使用的存储库中的 .git/config 具有正确的 user.email,它在 ~/.git-credentials 中有一个匹配的条目。它只是不使用该条目。
小智 11
对我有用的是在 .git 文件夹中我打开了配置文件。
现在你需要插入:
[credential "https://github.com/yourProjectPath"]
username = yourGithubUsername
Run Code Online (Sandbox Code Playgroud)
在此之后,您可以使用:
git config credential.helper store
Run Code Online (Sandbox Code Playgroud)
这会将其添加到配置文件中:
[credendial]
helper = store
Run Code Online (Sandbox Code Playgroud)
确保配置文件最后有此部分,并且在您之前添加的“凭据”部分之前没有重复
然后运行:
git pull
Run Code Online (Sandbox Code Playgroud)
并填写您的密码。
如果您使用的是 Ubuntu Linux,首先要做的就是通过 .gitignore 将 Git 更新到最新版本git-core/+archive/ubuntu/ppa。
sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update
Run Code Online (Sandbox Code Playgroud)
然后检查 git 2.9.3 是否仍然存在问题。
就我而言,在 github.com 中有两个条目
~/.git-credentials,第一个条目在我拉取的 repo 文件夹中是错误的Run Code Online (Sandbox Code Playgroud)https://username-2:********@github.com https://username-1:********@github.com https://username-1:*********@gitlab.com https://username-1:*********@bitbucket.org