← journal
one of the most shocking things i’ve encountered in my early career as a junior dev is the fear surrounding git rebase -i .
even amongst some of my co-workers, who are in many ways, magnitudes smarter than i am, it seems to be a pattern in a lot of devs to be afraid of this command.
what it actually does
when you run:
git rebase -i HEAD~4
git does something delightfully mundane: it opens a text file. if you are working out of the terminal and haven’t fiddled around with your git settings, git config --global core.editor "_YOUR-EDITOR_" is a good way to allay your fears of conquering vim.
pick a1b2c3d Add user model pick e4f5g6h Fix typo in user model pick i7j8k9l Add login endpoint pick m0n1o2p WIP debugging login # Commands: # p, pick <commit> = use commit # r, reword <commit> = use commit, but edit the commit message # s, squash <commit> = use commit, but meld into previous commit # f, fixup <commit> = like "squash" but discard this commit's message # d, drop <commit> = remove commit
a worthy thing to note here for new rebasers is that this is a plan, not an action. nothing has technically happened yet, aside from the fact a rebase has begun. if you change your mind, you just run git rebase --abort and either restart or give up (ideally the former).
each line is an instruction, in which a replaying of the commit you target is commenced. you may mix and match these instructions to your liking.
... continue reading