简体   繁体   English

GIT:致命:创建新分支时无法从远程存储库读取

[英]GIT: fatal: Could not read from remote repository when you create new branch

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://git@github.com/myName/myRepo.git
        fetch = +refs/heads/*:refs/remotes/origin/*
        pushurl = ssh://git@github.com/myName/myRepo.git

This is origin: 这是起源:

origin  ssh://git@github.com/myName/myRepo.git (fetch)
origin  ssh://git@github.com/myName/myRepo.git (push)

Any of you knows why of this error? 你们谁都知道为什么会出现此错误?

I'll really appreciate your help 非常感谢您的帮助

Double-check: 再检查一遍:

  • your GitHub ssh setting 您的GitHub SSH设置
  • the exact case (upercase/lowercase) of your url myName/myRepo.git 网址myName/myRepo.git的确切大小写(大写/小写)
  • if the issue persists with an https url 如果问题仍然存在,并带有https网址

     git remote set-url origin https://github.com/myName/myRepo.git 

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. 不确定OP是否解决了他的问题,但是对于将来的参考(因为这不久前对我有所帮助哈哈),问题在于SSH / OAuth授权。 I resolved my situation by replacing the OAuth for terminal access and updating my gitconfig file: 我通过替换OAuth进行终端访问并更新gitconfig文件解决了我的情况:

** OSX Sierra Platform ** ** OSX Sierra平台**

  1. Check your config file via the git config -e command. 通过git config -e命令检查您的配置文件。
  2. Open your keychain app. 打开您的钥匙串应用程序。
  3. Search for github.com || 搜索github.com || org.github.com if you're in an organization's enterprise repo. org.github.com(如果您在组织的企业仓库中)。
  4. Select the keychain entry appropriate github -- OF TYPE "Internet Password". 选择适用于github的钥匙串条目-类型“ Internet密码”。
  5. Edit the password via pasting in the OAuth key. 通过粘贴OAuth密钥来编辑密码。
  6. 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 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. Git在github上有大量的文档记录,因此,如果遇到麻烦,只需在其上进行快速搜索即可(或stackoverflow ...),希望它不会太难清除。 People are awesome at helping out, so don't be afraid to ask a dumb question! 人们乐于助人,所以不要害怕问一个愚蠢的问题!

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

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