Article URL: https://cachebag.sh/journal/interactive-rebasing/ Comments URL: https://news.ycombinator.com/item?id=49053385 Points: 27 # Comments: 21

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. 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. 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. 1. in this example, git is going to 'pause' on the first commit, allowing you to reword its message. 2. d or a drop deletes the WIP debugging commit entirely. this same result can be achieved by simply deleting the line entirely. the middle two commits were untouched, despite us mutating the surrounding commits. the end result is 3 total commits instead of 4.