DEV Community

Jose Ross Barredo
Jose Ross Barredo

Posted on

Explain git pull --rebase to me like Im five

I have been using git for years now and honestly, I really don't quite understand how certain codes work like for in this case git pull --rebase. Can someone explain to me how rebase works like I'm five?

Thanks and you're awesome!

Top comments (4)

bgadrian profile image
Adrian B.G.

As a 5y old you started alone to build a Wood Wagon specifically for the mars Planet Atmosphere & gravity.

You put aside the wagon after you finish it, because your parents tels you we haven't colonize Mars yet.

After 35 yrs, the wagon is rotten, cannot be used, but you won a ticket to Mars and wait it so bad.

You find this Time Machine and hit the "rebase" button, while whispering "I wish I could bring my Mars Wood Wagon here & now". And Voila!

The Wagon is moved trough the history, and magically rebuilt in front of you. You get your wooden wagon here and now, you pack it and go on Mars with it. The Wagon building steps were erased from the history and you remember as you were building it today, not 35yrs ago.

Now ... I said alone, because if when you were 5y and built the Wagon, one of your friends have helped you, now ... when you moved it trough the history ... something really bad would happen. He will have memories of a thing that didn't existed.

Rebase, like a Time Machine is very powerful, should not be used lightly.

Disclaimer: I recommend NOT to use rebase for many reasons, try git merge --squash if you want this effect, but the history should remain as it was, not as we want, we should learn from history.

Wood Wagon - your commits on an old branch, put on hold while others developed the master. You want to bring the branch in a newer master.
5y Kid - you as developer
World - the repository
Time - commit order (A-B-C-D) in git history log
Friend - developer who helped you on that branch, and want to continue. You have to rebase --force your timeline into his, erase his memories too.

anan474 profile image
Agung Tuah Ananda

explained beautifully, thanks a lot!

gonedark profile image
Jason McCreary
theodesp profile image
Theofanis Despoudis