I understand that, in general, git rebase -i
and git reset
are used for very different things.
But in the context of deleting the most recent N commits, it seems to me they are (or can be) identical. I even did an experiment (with two different local copies of my repository) and as far as I can tell they are the same. I'm just posting this question in case someone out there can point out where maybe I am missing something. So here is what I did.
I had a need to remove the most recent 11 commits (never mind why).
I tried two ways of doing it, and they appear to be completely identical; just wondering if I am missing anything in that they are not really identical:
git rebase -i HEAD~12
git reset --hard HEAD~12
These two methods appear to have done exactly the same thing. Is that correct?
Thanks much. Just trying to understand git a little deeper than I do now.
One difference is in their treatment of a dirty tree (files modified but not committed).
git reset --hard
will trash said changes, while git rebase -i
will ask you to stash them first.