After recently taking a programming course online which required us to upload our homework assignments into Github, ever since then whenever I type git push -u origin master
I get:
remote: Permission to my-github-username/mygithubrepo.git denied to rheros.
fatal: unable to access 'https://github.com/my-github-username/mygithubrepo.git/': The requested URL returned error: 403
rheros
is the name of the repository that I used to push my homework assignments to. Obviously, now I'm not using rheros
anymore, yet the command line thinks I'm still trying to push to it. I tried checking whether I have a faulty SSH key, but everything looks fine.
How can I make my command line effectively forget about the existence of a completely irrelevant directory that I pushed to before?
EDIT
git remote --verbose
gives:
origin https://github.com/my-github-username/mygithubrepo.git (fetch)
origin https://github.com/my-github-username/mygithubrepo.git (push)
So far, none of the suggestions below have helped me: it seems that the rheros
repo is running somewhere in the background of my command line, and I can't figure out how to eliminate it.
You will need to 1) fork the project you want to make changes to into your own github account, 2) clone that forked repo to your local, 3) make changes, 4) push to your own repo.
If git push origin master not working , all you need to do is edit that file with your favourite editor and change the URL = setting to your new location. Assuming the new repository is correctly set up and you have your URL right, you'll easily be able to push and pull to and from your new remote location.
If you want to revert the last commit just do git revert <unwanted commit hash> ; then you can push this new commit, which undid your previous commit. To fix the detached head do git checkout <current branch> .
Sometimes, Git can't make your change to a remote repository without losing commits. When this happens, your push is refused. If another person has pushed to the same branch as you, Git won't be able to push your changes: $ git push origin main > To https://github.com/USERNAME/REPOSITORY.git > !
First check what the current git repository is, if any using:
git remote -v
Then, confirm your new repository exists by checking the github website and copying the right repository url
Overwrite the repository url by running:
git remote add origin https://github.com/my-github-username/mygithubrepo.git
Try git push again:
git push origin master
git remote remove origin https://github.com/my-github-username/mygithubrepo.git
After this, you can add the repository you want to push to normally
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With