When I read about git-rebase, I understood the rebased commits should get lost. I say should because I noticed that, knowing the rebased commit sha, I can recall it.
Suppose I have the following three commits
A -> B -> C
where C's sha is cshaid. Then, if I interactively rebase fixing-up C into B with git rebase -i HEAD~2 and then I check the result with git log, I obtain the expected result, meaning
A -> B'
where B''s sha is different from B's sha.
However, running git log cshaid shows again
A -> B -> C
Questions: is this a known behavior? I tried reading git rebase --help but couldn't find related info. Why rebased commits are not simply forgot? I mean, rebase is kind of a dangerous operation to be performed only if you know what you are doing and you can do it, which is the point in having a dirty index (or wherever these useless commits are kept)? Am I missing something?
Step to reproduce (and to better understand my doubts). If you are willing to reproduce the situation, try with:
mkdir sampledir && cd sampledir && git inittouch file && git add -A . && git commit -m "Initial"- edit file, then
git commit -am "First modification" - edit file, then
git commit -am "Second modification" git log, you will see three commits, remember the sha forSecond modificationgit rebase -i HEAD~2, thefixupSecond modificationintoFirst modificationgit log, you will see two commits, where the sha forFirst modificationis now different than in step 5- however,
git log sha-for-"Second modification"will show the exact same tree as point 5 in this list