Home > Enterprise >  How can I revert commits by others in Git?
How can I revert commits by others in Git?

Time:10-28

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?

CodePudding user response:

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.

CodePudding user response:

Try doing a git commit or git stash. As in the previous answer your stage must have something that prevents the commit.

  • Related