As you can see, the feature branch has completely new commits. As said before, same set of changes, but completely different objects from the git point of view. And you can also see that previous commits are not destroyed. They are simply not directly accessible. If you remember, a branch is only a pointer to a commit. Therefore if neither branches nor tags are pointing to a commit it becomes almost impossible to reach, but the commit still exists.

Let’s now talk about this famous golden rule.

The golden rule of rebase

“No one shall rebase a shared branch” — Everyone about rebase

You have probably came across that rule, maybe phrased differently. For those who haven’t, this rule is quite simple. Never, NEVER, NEVER, rebase a shared branch. By shared branch I mean a branch that exists on the distant repository and that other people on your team could pull.

Too often this rule is thrown as a divine truth and I think understanding it could be a good thing if you want to improve your understanding of git.

To do that, let’s imagine a situation where a dev breaks the rule and see what happens.

Let’s say Bob and Anna are both working on the same project. Here is an overview of both Bob’s, Anna’s repos and the remote on GitHub: