PyCharm Github Push failed: Repository not found

In PyCharm I got an error like:

Push failed: Repository 'https://github.com/xxx/my-repository/' not found

I was able to do pull, fetch and check the history but when I tried to do a commit and push the error was raised. My changes are targeted to new branch which was created by me. And I had to push the new branch to the origin. I started to investigate what could be the reason for the problem and I found that there could be many reason for this issue:

Unfortunately or fortunately I got all of them. So I'll start to explain about their solution one by one.

Change git user for PyCharm project

First I wanted to be sure that I'm using the correct user to make the commit and the push. In order to ensure which user was used for the commit and the push you can check in:

  • Show Version Control - Alt + 9
  • Go to tab Log
  • Check the failed commit for the username

I my case the user was wrong so I decided to see what are the global settings for git on my system by:

git config user.name

result:

my_name

To list everything in the git file:

git config --list

result:

user.name=xxx@xxx.xxx
user.email=xxx@xxx.xxx
core.autocrlf=input
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.url=https://github.com/xxx/xxx.git

Next step is to solve the git user. You can change it globally or just for the current PyCharm project. In my case I wanted to change the user only for the current project. You can do it by:

  • Open your root folder of the project

  • Find hidden folder named: .git

  • Open file config

  • Add this section to it:

    [user]
    name = xxx@xxx.xxx
    email = xxx@xxx.xxx

You will be prompted for password later. If you want to change the global settings for the user or how to setup git for Windows or Linux you can check this article: PyCharm and Git complete tutorial

As a side note some users explain that if they change the remote address to:

https://user@github.com/xxx/my-repository/

from

https://github.com/xxx/my-repository/

They were able to solve the problem.

PyCharm check the repository address

Even after the change of the user I was not able to push my commits. The error was still the same. Then I verified the shown address in the error with the one in PyCharm remotes:

  • Main Menu
  • VCS
  • Git
  • Remotes

I found out that the address there was wrong. So I change the address with the address from the website: github. Unfortunately the error was still present.

Verify the github rights for user

Finally I decided to test the operation using the github.com. I open the repository then follow the steps for creating new branches in Github:

  • Open the repository
  • The branches drop down menu
  • Right the name for the new branch
  • If you have rights you should see: Create Branch: TestX from develop

If you don't have rights you will miss this option. Then you will need to requests rights for you.

Selection_034

This final change was able to resolve the problem. I'm not sure if all steps were needed to solve the problem but I believe that I needed to do them anyway.

Optimal steps to investigate git issue

As a general steps to verify git errors:

  • Double-check the url of the repo(case sensitive)
  • Verify is the repo public
  • Check the git user and config file
  • Check the user privileges
  • Check if you have read-write access.
  • Check the command line ( without PyCharm )
  • Test the operation in the website

Happy commits and successful pushes!

P.S. Lets have fun with comment from StackOverflow really funny comment:

Gotta love those useful Git error messages. Can't find the repository that I just cloned from, huh? Liar.

Related Article