Git Push ERROR: Repository not found

I have been trying to make a change to some code, and then to push the changes to my own githhub repository. In the local checkout (i.e. on my Mac) I created a new branch on which I committed a single change to the code.

Then I removed the origin as follows:

git remote remove origin

and added my new origin, pointing to my own github repository, as follows:

git remote add origin

Then, I tried to push the local code to that repo using the command

git push --set-upstream origin mynewbranch

but I got an error

remote: Repository not found.

fatal: repository '' not found

Am I missing something? Do I have to do something else?

Also, the token I have been using does contain EVERY known right for my github user. (Also, the above mentioned token is not the real token of course).

What do I have to do to commit the changes to a new repo in my own github?

404 (“not found”) is the usual response if you try to access a repository without the right credentials. So something is going wrong with authentication.

Don’t include the token in the URL, use just the repository URL, e.g. Then enter the token when asked for your password after entering your username. I recommend keeping the token in a password manager, you can use the Git credentials cache (or store, if you really want to store it unencrypted) for convenience.

Thank you for your reply, but your suggestion does not seem to work.

I removed the origin using the command

git remote remove origin

and then I added it as follows:

git remote add origin

Then I tried to push the code using the command

git push --set-upstream origin mynewbranch

which resulted in the following error:

remote: Repository not found.
fatal: repository '' not found

I was NOT asked for any password!

Is there something else I can try? Or should I create a bug report on github support?

The one explanation I can think of is that you already have cached credentials somewhere, so Git uses them, but they don’t work. If that’s the case the solution is to either remove or update those credentials. Where they might be depends on the system. I’m not familiar with MacOS myself, but there’s something about that in the documentation:

As a side note, repo and workflow scopes should be enough.

Thanks for that hint, but this also did not work. I removed the entry for “” from the keychain, then I used the following command again

git push --set-upstream origin mynewbranch

after which I saw this error again:

remote: Repository not found.
fatal: repository '' not found

So what else can I try?

I found a way to remove the credentials, it is the command

git config --global --unset credential.helper

After that, I am asked a username and password when I use the command

git push --set-upstream origin mynewbranch

I have been using my username and the personal access token (with every possible right), but I get the following error message

Username for '': alex4200
Password for '':
remote: Repository not found.
fatal: repository '' not found

I even created a new access token, just to be sure. It does not help, I still get the same error message.

Any ideas? Can this be so difficult?

For other repositories it seems to work. I was able to push. But not for this one.

That sounds really odd, but I’m glad at least others work!

Having the / at the end of the URL seems questionable. I’d be surprised if it makes a difference, but might be worth a try. Other than that I can only think of looking at git remote show origin to see if anything looks questionable.

I do not add this ‘/’ at the end of the URL. That also looked odd to me, but git is doing that. When I add a new origin, I do not use a ‘/’ at the end.

The solution seems to be that you first have to create this repository manually!

So, in order to make a pull request to some repository you have to follow the following steps:

  1. git clone the repo you want to make changes to
  2. Make the changes, add the files and commit the files on a new branch
  3. Go to and manually create a new repository
  4. Remove the origin: git remote remove origin
  5. Add a new origin: git remote add origin
  6. Possibly remove credentials: git config --global --unset credential.helper
  7. Push to the new repo: git push --set-upstream origin
  8. To create a pull request on the ORIGINAL repo: ???

I think I am missing something.I will ask a new question

Yes, that’s the case. :sweat_smile:

In that case you need to click the “fork” button for the original repository, instead of creating a new one from scratch. That’ll give you a linked copy in your account.

Yes, I forgot about “forking” something. But maybe there are two ways:

  1. Fork the repo
  2. checkout the forked repo
  3. make the changes
  4. push to forked repo
  5. create PR fork → original repo

But maybe that is not required. The following procedure also seems to work:

  1. Clone the original repo
  2. Make a new branch
  3. make the changes
  4. push the branch to original repo

No fork needed at all.

Does this sound right?

The second procedure works if you have write access to the original repository. :slightly_smiling_face:

Ah thanks, I try to remember that.

Viele Grüsse

1 Like