Search code examples
gitgithubgit-pushgit-revert

How can I undo the unexpected push to GitHub with another user credentials


I'm simultaneously working with my github repositories and client git repository. Today, I did modifications on my git code and unexpectedly committed with client credentials. After commit I realised that I committed the code with client username and email, then I set git config --global user.name "myname" and git config --global user.email "ex@gmail.com" to push the code to my repo. Code pushed successfully. But my problem is, I can see the commit was made by client credentials. And also his name added to contributors list. You can see below You can see here: How can I remove him from my contributors and I want to undo the push completely. Thanks in advance.


Solution

  • If this is the last commit, you can edit the message and reset the author with git commit --amend --reset-author to set it to your current config.

    Then, you have to git push --force the push to remove the commit with the wrong author.

    If this is not the last commit, you can use git rebase --interactive and reset the commit you want.