git.md (496B)
1 # Git 2 3 Undo last 2 already pushed commits: 4 5 ``` 6 git revert HEAD HEAD~1 7 ``` 8 9 (If the commits have already been pushed to a shared remote, use git revert 10 instead — it creates new "undo" commits rather than rewriting history, which 11 avoids causing problems for collaborators. ) 12 13 And the push it back to repo: 14 15 ``` 16 git push origin <branch-name> --force-with-lease 17 ``` 18 19 (This rewrites remote history and can break things for anyone who has already 20 pulled those commits — avoid on shared branches.)