Live data from Hacker News

Git rebase -i is not that scary

cachebag.sh

11–20 of 155 posts

Re: Git rebase -i is not that scary

#11

I really love the emacs interactive rebase mode, which comes up by default when you have EDITOR=emacs and do rebase -i. I know you can do this from within magit as well but I've never gotten into that workflow.

The nice thing with magit is how easy it is to manipulate hunks and line, truly editing commits with a surgical precision, all with an handful of keybindings.

Re: Git rebase -i is not that scary

#12
Another git command I love using is `git add -p`. I always want to commit in chunks as I go but sometimes I wait to long or realize later I could have broken it up. Being able to select only pieces of a file to add to a specific commit is so great. Editing the chunks manually can be a bit intimidating but since it only stages the change you can always restore the file and try again if the diff doesn't look right after the add.

Re: Git rebase -i is not that scary

#13

I feel like if you're scared of rebasing, you don't actually understand git.

My fear has never been rebasing itself, but that I make some kind of mistake with a random change conflict and don't notice it because it's not tested for directly. But I'm also not sure if that's categorically a git fear. (Edit: related to this, I think this sort of minor "itchy worry" is grounded in how sometimes conceptually simple diffs look messy during conflict resolution.)

Re: Git rebase -i is not that scary

#16

Big rebase fan here. I find myself using squash the most.

    pick a1b2c3d Add user model
    s e4f5g6h Fix typo in user model
    pick i7j8k9l Add login endpoint
    s m0n1o2p WIP debugging login endpoint
    s feedbee fixed login endpoint
    s deadbee fixed login endpoint
    s adebade fixed login endpoint
    s abcdefg actually fixed login endpoint
Of course, I get reminded about f/fixup every now and then - think "golly, that will save a second or two" and promptly forget.

Re: Git rebase -i is not that scary

#18

I feel like if you're scared of rebasing, you don't actually understand git.

The part where git needs to be “understood” is the entire problem. “Do one thing and do it well” was the whole mantra, which was completely ignored with the disaster that is git. It’s objectively awful.

Re: Git rebase -i is not that scary

#19

I really love the emacs interactive rebase mode, which comes up by default when you have EDITOR=emacs and do rebase -i. I know you can do this from within magit as well but I've never gotten into that workflow.

The nice thing with magit is how easy it is to manipulate hunks and line, truly editing commits with a surgical precision, all with an handful of keybindings.

Even just rebase fixup a commit that is a few commits below HEAD is just a few chords away. Use it many times a week when working.

Re: Git rebase -i is not that scary

#20

I feel like if you're scared of rebasing, you don't actually understand git.

Reflog is, as the article says, the permission to do all kinds of crazy things, including rebasing. Once you realize any committed state is recoverable for a good period of time it really frees you.

Plus you can always take a note of the commit hash before you do anything crazy. But reflog means you don't have to.

Git really does have all the features you need. I wouldn't argue with anyone complaining about the UI to get there. But it's all in there somewhere.

Post reply on HN