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"git commit -am "First modification"git commit -am "Second modification"git log, you will see three commits, remember the sha for Second modificationgit rebase -i HEAD~2, the fixup Second modification into First modificationgit log, you will see two commits, where the sha for First modification is now different than in step 5git log sha-for-"Second modification" will show the exact same tree as point 5 in this listYes, this is the expected behavior. Unreferenced commits will eventually be garbage collected and thereby purged from disk. They're kept around for a number of days (by default 14), but before that 14-day timer even starts ticking the objects must have expired from the reflog as well (unreachable objects by default expire after 30 days).
Related StackOverflow questions:
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