git config --local --list // Returns user.email me@projectemail.
git config --global --list // Returns user.email me@workemail
git config --list //returns work email, then local email
git push // rejected because attempted to use work email
Any suggestions how to overcome this? I still want to maintain my work email as the default as it is the normal one I use for GitHub, but not for this specific project which is not work based.
CodePudding user response:
The configuration listed with git config
only affects new commits. Whatever commits you already have in your repository (including pull/merges/cherry-picks of commits created with your work email) are unaffected by that configuration.
So I am guessing that you maybe have some commits created with your default work email before you added the local repo specific email configuration.
But regardless of cause, if having some commits associated with your work email causes problem and you want to change them to be authored by your project email instead you need to amend the commits.
If it only is one or a couple of commits that have wrong email, you can rectify this by doing an interactive rebase (possibly with --rebase-merges
to keep merge commits) and amend the commits with --reset-author
.
If there are several commits then you probably want to use git filter-repo.