Want to change the email id that has access to private repo and to push changes from that new mail id

So, let started !!

Here’s a step by step solution to do this

Disclaimer: Keep in mind that you have to be access of that private repo from the mail id which you gone change .

  1. First of all see the which email id you used to commit the last changes by using the following git command in terminal :

git log — author=”incorrect-email”

Ex: git log — author=”Abc@example.com

This command will show the last commit along with it hash code(40 character alpha-numeric code generated by Git), Author name, date, commit name.

2. Then you have to use the following command to change the email id which has access to private repo. You just need to replace the email id with the one which you have access to private repo :

git config user.email

Ex: git config user.emailcorrect-xyz@example.com

3. To confirm that email id is changed or not you can use the following command :

git congif user.email

4. Then you have to use the the following git command amend in which you have to described the author name, author name could be anything, you can set author name according to your own choice, then your complete new mail id which has access to private repo. After entering this command there a editor will open in terminal, so to come out of that by saving the changes you can use :wq + Enter if it’s a vim editor, or ctrl+x+Enter , or ctrl+s+Enter , to come out of that editor in vscode or anyother IDE.

git commit — amend — author=”Author name <\>”

Ex: git commit — amend — author=”xyz <xyz@example.com\>”

5. If you want to check that your commit has done by using the new mail id or not you can use the git log command , this will display all the information related to the commit like commit hash (this hash is different from the old hash which is associated with your old email id), author name, email id , date

git log

here some sort of code you gone see :

commit <Hash code>(HEAD -> <branch name>)
Author: xyz <xyx@example.com\>
Date: Sun Jan 17 15:30:02 2023 +0530

“Commit Name”

6. Final step you have to push code and for pushing code you gone use normal push command like :

git push origin <branch-name>

Ex: git push origin develop

Here the steps are complete and you sucessfully push code to the repo using the valid or accessible mail id by the repo maintainer.

Hope soo, it would help you a little bit. Like it if you resolved your issue by following this, and if there are something wrong please comment down below.

Thankyou for reading !!