Explain git pull --rebase to me like Im five

twitter logo github logo ・1 min read

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!

twitter logo DISCUSS (4)
markdown guide
 

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.

 
 
 
Classic DEV Post from Jun 30

What is your favourite Git command?

Jose Ross Barredo profile image
25. Coder. Noob. INTP-T

Customize DEV by logging in

  • Follow users
  • Follow tags
  • Dark mode
  • Font style (like sans serif)
  • Notifications
Get Started