How would I "rollback" the last commit in git without deleting any changes?
This is something I've done often in hg:
1 mm of Hg pressure is equivalent to one torr and one torr is equivalent to 133. 3 N/m2.
The git revert command is used for undoing changes to a repository's commit history. Other 'undo' commands like, git checkout and git reset , move the HEAD and branch ref pointers to a specified commit. Git revert also takes a specified commit, however, git revert does not move ref pointers to this commit.
If you want to revert changes already committed: To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME .
The hg backout command lets you “undo” the effects of an entire changeset in an automated fashion. Because Mercurial's history is immutable, this command does not get rid of the changeset you want to undo. Instead, it creates a new changeset that reverses the effect of the to-be-undone changeset.
Try this:
git reset --soft HEAD^
I found it to be the same of 'hg rollback', because:
You can also create a rollback
git alias like this:
git config --global alias.rollback 'reset --soft HEAD^'
So, you can now just type git rollback
to have exactly the same command that you have on Mercurial.
With git you may actually prefer to use the --amend
option in that case.
git commit --amend
and edit the notesIf you need to rollback for other reasons take a look at git revert
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With