0

Trying to make a simple change to a Git repository, privately hosted with GitHub. I cloned the repository, made the change and went to push it up for review. The git push didn't succeed and I thought maybe I had fat fingered the remote URL when I cloned the repository (but that couldn't be right because I'd successfully cloned the repository, right?). I tried removing and re-adding the remote but pushing still fails:

To illustrate the problem:

% git remote -v               
origin    https://github.com/our-organisation/some-repository.git (fetch)
origin    https://github.com/our-organisation/some-repository.git (push)

% git fetch -v origin
From https://github.com/our-organisation/some-repository
= [up to date]        MO_Adding_ECS_configs             -> origin/MO_Adding_ECS_configs
= [up to date]        update_gems                       -> origin/update_gems

% git push -v origin
Pushing to https://github.com/our-organisation/some-repository.git
remote: Repository not found.
fatal: repository 'https://github.com/our-organisation/some-repository.git/' not found

[Some names may have been changed.]

Why does GitHub say, "Repository not found" when the remote URL is correct?

johnsyweb
  • 136,902
  • 23
  • 188
  • 247

1 Answers1

0

Check your write permissions on the repository!

Some of my colleagues helpfully suggested I try an SSH remote. So I do this...

% git remote add ssh git@github.com:our-organisation/some-repository.git

% git fetch ssh
From github.com:our-organisation/some-repository
* [new branch]        MO_Adding_ECS_configs             -> ssh/MO_Adding_ECS_configs
* [new branch]        update_gems                       -> ssh/update_gems

% git push ssh     
ERROR: Repository not found.
fatal: Could not read from remote repository.

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

"The correct access rights?"

Well why didn't you say so?

It's worth noting at this point that while the SSH failure mode in this scenario is slightly better, I use HTTPS remotes over SSH because GitHub recommend HTTPS over SSH.

I understand that GitHub uses "Not Found" where it means "Forbidden" in some circumstances to prevent inadvertently reveling the existence of a private repository. This is a fairly common practice around the web.

Requests that require authentication will return 404 Not Found, instead of 403 Forbidden, in some places. This is to prevent the accidental leakage of private repositories to unauthorized users.

--GitHub

What makes no sense to me is when I am authenticated with GitHub using a credential helper and I have access to that repository (having successfully cloned and fetched it) that GitHub would choose to hide its existence from me because of missing write permissions.

Checking https://github.com/our-organisation/some-repository/ using a web browser confirmed that I didn't have write permissions to the repository. Our team's GitHub administrators were able to grant my team write access in a short time and I was able to push the branch up.

Hopefully this Q & A will help folks in the future.

johnsyweb
  • 136,902
  • 23
  • 188
  • 247