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 https://ghp_uac2zM5Uk37OHgOGGrbDBhHO2zgdt9Z3cOUT@github.com/myrepo/pushtest.git
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 'https://ghp_uac2zM5Uk37OHgOGGrbDBhHO2zgdt9Z3cOUT@github.com/myrepo/pushtest.git/' 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. https://github.com/myrepo/pushtest.git
. 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 https://github.com/myrepo/pushtest.git
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 'https://github.com/myrepo/pushtest.git/' 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 āgithub.comā 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 'https://github.com/myrepo/pushtest.git/' 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 'https://github.com': alex4200
Password for 'https://alex4200@github.com':
remote: Repository not found.
fatal: repository 'https://github.com/alex4200/pushtest.git/' 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:
- git clone the repo you want to make changes to
- Make the changes, add the files and commit the files on a new branch
- Go to github.com and manually create a new repository
- Remove the origin: git remote remove origin
- Add a new origin: git remote add origin https://github.com//.git
- Possibly remove credentials: git config --global --unset credential.helper
- Push to the new repo: git push --set-upstream origin
- 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. 
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:
- Fork the repo
- checkout the forked repo
- make the changes
- push to forked repo
- create PR fork ā original repo
But maybe that is not required. The following procedure also seems to work:
- Clone the original repo
- Make a new branch
- make the changes
- 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. 
Ah thanks, I try to remember that.
Viele Grüsse
Alex
1 Like