[go: up one dir, main page]

DEV Community

Cover image for Explain git rebase to me like I'm five
Vicente G. Reyes
Vicente G. Reyes

Posted on

Explain git rebase to me like I'm five

Photo by Sebastian Herrmann on Unsplash

How does this work?

Top comments (5)

Collapse
 
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: app.pluralsight.com/course-player?...

(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)

Collapse
 
sabderemane profile image
Sarah Abd

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

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.

Collapse
 
codecustard profile image
Emmanuel Barroga

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

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

Collapse
 
thebuzzsaw profile image
Kelly Brown

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