DEV Community

Discussion on: Explain to me git rebase

Collapse
 
recursivefaults profile image
Ryan Latta • Edited

Okey dokey, I'm gonna take a different approach to answer this. A lot of folks are focusing on what pull --rebase does which is only a portion of how rebase works.

Imagine a group of friends standing around sharing a story. Each person adds their part to the story, then the next says, "Yeah, and then..." before adding their part. This is how git organizes commits, even branches.

Now, someone shows up to the group of friends, gets in the middle of them and says, "No no no, you got it all wrong!" And proceeds to tell everyone the entire story their way. This is what rebase does. It completely alters the story.

Rebasing is a desctuctive with few means to recover

You can alter the story in your head all you want before you speak it. Once you speak it though, you must never change it. In other words, you can rebase anything you've not pushed and you only mess yourself up. Once you push it though, you're altering everyone's story and that is extremely dangerous.