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

Viewed 23379

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:

[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

2 Answers

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:

** OSX Sierra Platform **

  1. Check your config file via the git config -e command.
  2. Open your keychain app.
  3. Search for github.com || org.github.com if you're in an organization's enterprise repo.
  4. Select the keychain entry appropriate github -- OF TYPE "Internet Password".
  5. Edit the password via pasting in the OAuth key.
  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. People are awesome at helping out, so don't be afraid to ask a dumb question!

Related