Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloning and Pushing a Branch into a Private repo

Tags:

git

github

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?

like image 351
lost9123193 Avatar asked Oct 16 '22 08:10

lost9123193


2 Answers

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.

like image 148
VonC Avatar answered Oct 20 '22 22:10

VonC


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
like image 33
Jaime Avatar answered Oct 20 '22 22:10

Jaime