GIT:致命:创建新分支时无法从远程存储库读取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45021310/
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
GIT: fatal: Could not read from remote repository when you create new branch
提问by user2924482
I'm create new branch and I'm trying to push the branch (I have tried the following commands):
我正在创建新分支并尝试推送分支(我尝试了以下命令):
git push --all -u
git push origin NewBranch
But in both cases I'm getting this error:
但在这两种情况下,我都会收到此错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
This is my .git/config:
这是我的 .git/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = ssh://[email protected]/myName/myRepo.git
fetch = +refs/heads/*:refs/remotes/origin/*
pushurl = ssh://[email protected]/myName/myRepo.git
This is origin:
这是起源:
origin ssh://[email protected]/myName/myRepo.git (fetch)
origin ssh://[email protected]/myName/myRepo.git (push)
Any of you knows why of this error?
你们中的任何人都知道这个错误的原因吗?
I'll really appreciate your help
我会非常感谢你的帮助
回答by VonC
Double-check:
再检查一遍:
- your GitHub ssh setting
- the exact case (upercase/lowercase) of your url
myName/myRepo.git
if the issue persists with an https url
git remote set-url origin https://github.com/myName/myRepo.git
- 你的GitHub ssh 设置
- 您网址的确切大小写(大写/小写)
myName/myRepo.git
如果问题仍然存在 https url
git remote set-url origin https://github.com/myName/myRepo.git
回答by Jesse
Not sure if OP ever solved his issue or not, but for future references (since this helped myself not too long ago haha), the problem is with the SSH/OAuth authorization. I resolved my situation by replacing the OAuth for terminal access and updating my gitconfig file:
不确定 OP 是否曾经解决过他的问题,但为了将来的参考(因为这对我不久前有帮助,哈哈),问题出在 SSH/OAuth 授权上。我通过替换终端访问的 OAuth 并更新我的 gitconfig 文件解决了我的情况:
** OSX Sierra Platform **
** OSX Sierra 平台 **
- Check your config file via the
git config -e
command. - Open your keychain app.
- Search for github.com || org.github.com if you're in an organization's enterprise repo.
- Select the keychain entry appropriate github -- OF TYPE "Internet Password".
- Edit the password via pasting in the OAuth key.
- Exit and retry to push to your repo, which should generate a pop-up asking for keychain access.
- If so, allow access.
- If not then you edited the wrong keychain or something didn't save correctly.
- 通过
git config -e
命令检查您的配置文件。 - 打开您的钥匙串应用。
- 搜索 github.com || org.github.com 如果您在组织的企业存储库中。
- 选择适合 github 的钥匙串条目——类型为“Internet 密码”。
- 通过粘贴 OAuth 密钥来编辑密码。
- 退出并重试推送到您的存储库,这应该会生成一个弹出窗口,要求访问钥匙串。
- 如果是,请允许访问。
- 如果不是,那么您编辑了错误的钥匙串或未正确保存的内容。
Git is documented on github pretty extensively, so if you run into a hiccup, just give it a quick search on there (or stackoverflow ...) and hopefully it won't be too hard to clear up. People are awesome at helping out, so don't be afraid to ask a dumb question!
Git 在 github 上有相当广泛的记录,所以如果你遇到问题,只需在那里快速搜索(或 stackoverflow ...),希望它不会太难清理。人们非常善于提供帮助,所以不要害怕问一个愚蠢的问题!