Undo the last git commit that was pushed to the beginning

I sent the wrong files to my branch and moved them to their original state. I saw an article in How to undo last commits in Git? that relate to canceling the local commit, but my problem is that I clicked commit origin. How to undo this?

+4
source share
2 answers

As you have already moved towards origin, your changes have been published for others to see and be distracted. Because of this, you probably do not want to rewrite the story. Therefore, it is best to use git revert .

This creates a new commit that rolls back the changes you made. Press the new commit and the origin will be fixed.

Here is an SO answer that provides more details on this.

+6
source
git reset HEAD^ git push origin +HEAD 

should work for you. See the git-push and git-reset documentation for more information on why.

+4
source

Source: https://habr.com/ru/post/1490618/


All Articles