Search code examples
gitrevert

How can I revert commits by others in Git?


I want to revert the commit of other and also I am not the contributor to that library I am simply an assistant which have to do some changes in the git repository. Till here I clone a repository and the file which I have to revert I found that commit using git log and found out that commit and when I do git revert commit_id I get this error.

error: your local changes would be overwritten by revert. hint: commit your changes or stash them to proceed. fatal: revert failed

My question is what should be the step which I have to take to revert the commit of others by keeping in mind that I am not a contributor or done anything for that repository?


Solution

  • That error isn't about permissions. It's about local changes that Git is protecting from accidental destruction. Deal with those first, with a commit, stash, reset, etc. When your stage is clear you'll be able to revert. Whether you can push is another matter, depending on permissions.