gitgit-interactive-rebase

What happens to the original commits when we use interactive rebase?


I am trying the interactive rebase. Assuming I have a linear master branch with 6 commits and the HEAD is on the 6th commit, and I run git rebase -i HEAD~4 then it allows me to pick/edit/split/squash the HEAD and the last 3 commits.

Once I do any of the action and complete the rebase operation, then it replays the commits on top of HEAD~4. Now, these have new commit ids and the head points to the most recent (picked) commit.

I want to know what exactly happens to the original commits? Are they deleted, are they retrievable?


Solution

  • When a commit isn't referenced any more by a branch or a tag, it often still is in the reflog.

    But when even the reflog clears up and the commit isn't referenced at all, then it becomes candidate for garbage collection, and ends up deleted, depending on your gc config.