DEV Community

Cover image for Explain git rebase to me like I'm five

Explain git rebase to me like I'm five

highcenburg profile image Vicente G. Reyes ・1 min read

Photo by Sebastian Herrmann on Unsplash

How does this work?

Discussion (6)

Editor guide
s_abderemane profile image
Sarah Abd

I love illustrations and pratice so I guess this is a good explanation :
You can find how rebase works but other things also :)

safventure profile image
Saf Venture

This is very informative. Illustrations provide better understanding. Thanks for sharing. :)

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.

mattcobley profile image
Matt Cobley

I'd highly recommend watching How Git Works by Paolo Perrotta on Pluralsight. There's a section on rebasing that I'll link to here, but it's best to watch the whole thing to pick up all of the background that makes this simple to understand:

(A bit of a cop-out response, I know, but I think this course is OUTSTANDING and will do a much better job than me of explaining it)

thebuzzsaw profile image
Kelly Brown

rebase = re-apply the commits on this branch to a different starting point

codecustard profile image
Emmanuel Barroga

Mommy branch and daddy branch merge and get a new baby branch.

Einstein gets human branch and robot branch and turns human branch into a cyborg.