I put in the wrong email and now I can’t push to my repository. How do I reset it?
Did you use the ‘git config --global’ syntax ? or just at the prompt when committing / pushing ?
At the prompt when commiting/pushing
Just try the commit / push again.
Or permanently store your credentials with ‘config --global’ or ‘credential-store’ option.
Wait no, I think I also used the --global syntax as well
By that I mean when it prompted me it told me to use --global
Then just run global again and change the credentials
I tried that, it didn’t work (unless I’m doing something wrong)
Might any of the mail addresses in your commits be ones that you’ve configured Github to keep private? In general it’ll be easier to help you if you post the exact error message (you can censor any private details).
Sure, give me a second
firstname.lastname@example.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
That error message has nothing to do with mail addresses, it means Github doesn’t accept your SSH key for login. This can have a bunch of reasons:
- There’s not SSH key available on your computer.
- You don’t have the right key loaded into the SSH agent (if it is password protected, or has a non-default file name).
- You don’t have the key for your current computer configured on your Github account.
I recommend taking a look at the documentation on Connecting to GitHub with SSH, it has pages for each of those possible problems.
Thank you, it worked! However it appears I have a new problem. When I try to push it tells me to pull, but when I try to pull it returns this error:
fatal: refusing to merge unrelated histories
That means your local repository has no commits in common with the remote one. Did you change the first commit by any chance (e.g. using
git rebase or
git commit --amend)?
I think I used git rebase once.
If that rebase changed the first (“initial”) commit in the repository that’s probably the reason. In general rebasing history that’s shared will have funny results.
There are a few things you can do to resolve this. But all of them carry a risk of messing up and losing data, so be very careful!
- If you are absolutely sure you want to keep the local version and are fine with losing everything on the branch you’re pushing to, you can use
git push --force. That will replace the remote branch with the local one.
- If you want to keep the remote history and add a few commits from the local branch, you can create a new local branch from the remote branch, and use
git cherry-pickto copy the commits you want. Make absolutely sure you got everything you want before deleting the old local branch!
- For completeness sake I’ll mention that there is a
git mergeoption to allow merging unrelated histories, but that is almost guaranteed to be the wrong choice for data that is supposed to have a common history.
Thank you, it worked! Thank you for all the help.