5

I was given access to a private repo shared for 5 people. I did a

git clone https://github.com/thecompany/theprogram.git

Then I made a new branch and tried to push it using the following:

git push --set-upstream the-new-branch

But I'm getting an error:

remote: Repository not found.
fatal: repository 'https://github.com/thecompany/theprogram.git/' not found

How can I push my branch onto github?

lost9123193
  • 10,460
  • 26
  • 73
  • 113

2 Answers2

2

Expectation is to be able to push to a private repo that I am able to clone, but unable to push a branch too.

It depends on what "unable to push a branch to" means.

If it is "repository not found" as in the original question, that means the credentials (potentially cached) used to authenticate when pushing are incorrect.
Test first if a git ls-remote https://<you>@github.com/<user-or-org>/<private-repo> works.

If it is a "permission denied" issue, the permission level might not be high enough (Ie: "read" or "triage" would allow a clone, not a push)

The OP confirms in the comments: he had only read access.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Yes by unable to push a branch I was referring to the original question. I have tried cleared credentials from osxkeychain. Doing ls-remote I get the list of remote branches with and without the repository listed directly as you suggested. I'm leaning toward a permission denied issue, but would that come back with `remote: Repository not found.` – Garrett Barlocker Aug 05 '20 at 22:07
  • @GarrettBarlocker are you using an HTTPS URL or an SSH one starting with `git@github.com:...`? – VonC Aug 05 '20 at 22:11
  • And yes, "not found" is a classic answer when you don't have enough rights: a security measure, in order to not reveal the remote repository you are trying to access to. – VonC Aug 05 '20 at 22:19
  • I am using a HTTPS URL – Garrett Barlocker Aug 05 '20 at 22:26
  • @GarrettBarlocker OK, so if you can clone, it is not a credential issue. Remains the permission level: how were you added to that private repository? With which rights? – VonC Aug 05 '20 at 22:47
  • Thanks @VonC it was a permissions issue I only had read-only – Garrett Barlocker Aug 05 '20 at 22:57
1

when you clone successfully, try this

first, checkout a new branch:

git checkout -b  the-new-branch

then, push to remote origin(default):

git push origin the-new-branch 

and, set upstream:

git branch --set-upstream-to=origin/the-new-branch
Jaime
  • 11
  • 2