2

I'm having problems pushing to git. Whenever I execute "git pull," it pulls from the repo I need. However, when I execute "git push" after committing, I get the following error:

  Permission denied
  fatal: Could not read from remote repository.

  Please make sure you have the correct access rights
  and the repository exists.

I verified that my ssh key is accurate. I only have one ssh key so I think it's unlikely that git is using the wrong key. "git pull" works fine. "My git config --list" shows the following:

  user.name=myusername
  user.email=myemail
  push.default=current
  remote.origin.url=theCorrectURL
  branch.thebranchiwannapushto.remote=origin
  branch.thebranchiwannapushto.merge=refs/heads/branchname
  mergetool.prompt=false
touch my body
  • 1,634
  • 22
  • 36

1 Answers1

3

You might need to configure push refs specifications to ensure the push is done to the desired branch. Maybe you only have push permission for certain branches.

msa
  • 702
  • 7
  • 14
  • 1
    Fine, but could you please explain how this is done? – dwilli Jul 21 '20 at 22:49
  • 1
    In the repository's git config file `.git/config`. See also: [official documentation](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec), [section in Atlassian's tutorial](https://www.atlassian.com/git/tutorials/refs-and-the-reflog#refspecs) and [SO answer](https://stackoverflow.com/a/44333810/757308) – msa Jul 30 '20 at 19:11
  • 1
    @dwilli if you're having this problem (like I did 5 years ago at my first internship), then more than likely someone who controls the repository needs to grant you write permissions to the repository. For example, I can `git pull` the `facebook/react-native` `master` branch onto my computer, but I cannot push my changes to `master` (because I don't have write permissions) – touch my body Aug 04 '20 at 21:45