DEV Community

Discussion on: Explain git rebase to me like I'm five

Collapse
 
recursivefaults profile image
Ryan Latta

Rebasing is a tricky concept to grasp, as well as its consequences.

Lets try this metaphor.

Imagine a heavy metal chain. Each link in the chain is a git commit. Each link knows about the one before it.

Most non-rebase commands work by simply attaching new links to the chain.

Rebase, on the other hand, breaks one of the links, and then rebuilds a brand new chain from that point.

The reason this matters is that when you use git you're sharing the chain. When someone makes a mistake with rebase, you have to solve the problem that someone else threw away that shared chain created a new one and has thrown it at you.

This is why most advice you'll find about rebasing follows a golden rule of you can rebase things that you've not shared/pushed.