Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics

Oh My Git!

An open source game about learning Git! · By blinry, bleeptrack

Can anybody explain reordering events with 'rebase -i' to me?

A topic by Reverend Speed created Apr 16, 2021 Views: 772 Replies: 2
Viewing posts 1 to 2

I think I'm okay with Cherry-pick, but I do not understand the instructions for 'git rebase -i'

FanTASTIC program, by the way!


I think of `git rebase -i` as a way to create a "recipe" of git operations, aka. a "Git sequencer". Each line in the rebase instructions correspond to a separate git command you would otherwise run at the command line.

So if you have three commits : A -> B -> C, and you want to reorder B and C, you could either run these commands:

  • git reset --hard A
  • git cherry-pick C
  • git cherry-pick B

or you could run `git rebase -i A` (which basically says "I want to rewrite the history since commit A") and then edit the instructions to say:

  • pick C
  • pick B

The end result after this is exactly the same, but I find the rebase method easier when the number of commits grow large and/or I want to make other kinds of changes to the history (reword commit messages, squash commits together, etc.)

Many, many days later - thanks @jherland, that's helpful! I went back to the game and got to grips with those commands. Cheers!