Git强制使用HTTPS
我创建了一个GitHub repo,然后使用SSH克隆了它:Git强制使用HTTPS,git,github,ssh,macos-mojave,Git,Github,Ssh,Macos Mojave,我创建了一个GitHub repo,然后使用SSH克隆了它: git clone git@github.com:BenReilly/all-the-characters.git 我添加了一些文件 git add . git commit -m "some message" git push 这导致提示输入我的用户名和密码。这本身就有点奇怪,但我还是进去了。然后我得到: > remote: Anonymous access to BenReilly/all-the-characters.
git clone git@github.com:BenReilly/all-the-characters.git
我添加了一些文件
git add .
git commit -m "some message"
git push
这导致提示输入我的用户名和密码。这本身就有点奇怪,但我还是进去了。然后我得到:
> remote: Anonymous access to BenReilly/all-the-characters.git denied.
> fatal: Authentication failed for 'https://github.com/BenReilly/all-the-characters.git/'
HTTPS?什么
git remote -v
> origin https://github.com/BenReilly/all-the-characters.git (fetch)
> origin https://github.com/BenReilly/all-the-characters.git (push)
啊
这是因为它不在我的osxkeychain中吗
为了确保我添加了ssh-K~/.ssh/
,并确保定义了~/.ssh/config
文件。行为没有改变。我还验证了密钥是否在我的GitHub设置中
我在MacOS Mojave(10.14.1)上,使用Git版本2.17.2
为什么Git强制使用HTTPS而忽略我设置SSH地址的尝试
ETA.git/config
文件
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = git@github.com:BenReilly/all-the-characters.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
Git配置有一个:
url..而不是
任何以该值开头的URL都将被重写为以
开头。如果某个站点为大量存储库提供服务,并使用多种访问方法为其提供服务,而某些用户需要使用不同的访问方法,则此功能允许用户指定任何等效URL,并让Git自动将URL重写为特定用户的最佳备选URL,即使是对于网站上从未见过的存储库。当多个insteadOf字符串与给定URL匹配时,将使用最长的匹配
基本上,如果你像
git config --global url.https://.insteadOf git://
[url "https://"]
insteadOf = git://
您将在全局Git配置中添加一节(~/.gitconfig
,在类似Unix的机器上),该节类似于
git config --global url.https://.insteadOf git://
[url "https://"]
insteadOf = git://
这将导致Git自动将任何以
Git://
开头的远程文件转换为以https://
开头的远程文件。用git config--global--list查看您的全局配置,看看是否有而不是条目。您的.git/config
文件是什么样子的?@lower我在上面添加了它git config--global
呢?我怀疑你在什么地方找到了一个条目。@Chris看起来确实是这样。这里有几个而不是条目。这些电话现在都超时了,我99%确定这是我被迫使用的代理。在这个网络上,我必须使用https。这有它自己的问题…好的,很好。现在我们知道问题出在哪里了,我要补充一个答案。