Posts

Showing posts from April, 2019

Git: Rollback an old commit

Try:  git checkout . (Don't forget . ) Undo: git reset --hard https://stackoverflow.com/questions/2007662/rollback-to-an-old-git-commit-in-a-public-repo

Git: Delete a commit in a remote branch

For latest commit: git reset --hard HEAD~1 / git reset --hard git push origin HEAD --force https://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git For old commits: git rebase -i Change pick to drop for commits which you want to delete. Maybe resolve conflict and continue rebase Change a new message commit git push --force

Git squash

P -> Q -> R \ .--> X -> Y P -> Q -> R \ .--> Z git rebase -i Change pick to squash for some commits which want to squash. Save and quit. Change a new message commit for squashing. Save and quit. git push --force https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing

Git: Changing a commit message

For the latest commit: git commit --amend I n text editor, edit the commit message, and save the commit. git push --force https://help.github.com/en/articles/changing-a-commit-message For old commits: git rebase -i ( previous commit which you want to change message) On top of text edtior, change pick to reword Change a new message commit git push --force https://stackoverflow.com/questions/1884474/change-old-commit-message-on-git