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
- delete commit lines from the 11 commits that I don't want, keeping only the commit just before them (the one at the top of the interactive rebase file).
- rebase succeeded
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.
question from:
https://stackoverflow.com/questions/65942954/git-rebase-vs-git-reset-hard-are-they-the-same-for-deleting-the-most-r 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…