Live data from Hacker News

Git rebase -i is not that scary

cachebag.sh

91–100 of 155 posts

Re: Git rebase -i is not that scary

#91

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.

sounds like someone accidentally delete your repo because they didn't understand git and did a dumdum :P

Re: Git rebase -i is not that scary

#92
post #80

A workflow I was introduced to and have worked with a lot in my teams is, 1. Everyone uses feature branches 2. Everyone cleans up their branch using interactive rebase on top of main before review 3. All merges have been freshly rebase on main I think it works very well and keeps the history clean while preserving "each commit does one thing".

I wish my team would at least use the rebase merge strategy by default to avoid branch graphs looking like the London tube network. Not in 10 years did I have an issue with that (okay, except accidentally rebasing deliberate no-ff merges).

The one time I suggested that, someone immediately came up to me trying to convince me that rebases are the most dangerous thing ever.

Re: Git rebase -i is not that scary

#93

Git rebase isn't scary at all, what's scary is the git rebase cult. I'll probably die never really seeing the tangible benefit a meticulously curated git history provides but at least I saw a few hundred blog posts and hn comments declaring the moral failure that is not having the cleanest commit history. The cynic in me would say that people are over-identifying too much with their recent bikeshedding addiction (jus…

I use git history to understand wtf my colleagues, and myself, where doing and thinking 10 years ago. A well structured, squashed commit and a clean history helps A LOT. I can't tell you how often I find a 'Apply review changes' and 'Fix shit' commit with no context. I then need to go back in the blame history or find what branch/PR this belonged too on GH to find even the context of these changes. Perhaps you don't work on the kind off crappy code bases I am dealing with, but a bit of git discipline saves a fuckton of frustrations.

tbf, this says a lot more about the code base, my colleagues and the shitty, lazy culture at our company that leads to ZERO ownership and architecture ;)

Re: Git rebase -i is not that scary

#95

I’ve used Git for 20 years now and wrote a book about it. The biggest mistake most sources make when teaching about history rewriting is omitting these two lessons first: - it’s easy to lose uncommitted data in Git and hard to lose committed data - given this, learn how to use ‘git reflog’ to see what you’ve done and how to undo/redo it (as this post recommends but, even then, a little too late) If you just get in th…

The most important thing to happen to git in its entire history is jj as a better porcelain to git, so that you don't need to read entire books to get it right.

Re: Git rebase -i is not that scary

#96
I use interactive rebases frequently, but even then, I think conflicts happening during a rebase are often somewhat cryptic.

I think I know what happens in principle (each step of a rebase does a merge of the commit from the list with the last rebased commit) but it's still often hard to understand which side of the conflict represents what, and what would be the desired outcome for that step in the history. So I tend to abort the rebase when I get a conflict and see if I can plan it differently so I can get it through without conflicts.

What I found good to know is that only actions that modify the actual changes in the history - reordering, deleting or editing commits - can cause conflicts. The other actions - reword, fixup or squash - only modify how the changes are grouped into commits and cannot cause conflicts.

So I usually do an interactive rebase in several passes: First a rebase that only reorders commits (or rarely does deletes or edits) and where I deal with the resulting conflicts, then a second pass for fixup or squash operations that can then use the reordered history from the first pass.

Rewords are both harmless and don't require any particular ordering, so can be done in any pass.

Re: Git rebase -i is not that scary

#97

Git rebase isn't scary at all, what's scary is the git rebase cult. I'll probably die never really seeing the tangible benefit a meticulously curated git history provides but at least I saw a few hundred blog posts and hn comments declaring the moral failure that is not having the cleanest commit history. The cynic in me would say that people are over-identifying too much with their recent bikeshedding addiction (jus…

I continual find the amount of ink spilled on having a clean commit history amazing, when you can basically get all the same benefits with:

git log --first-parent

git bisect --first-parent

Re: Git rebase -i is not that scary

#100
post #24

I found the VS Code GitLens extension to be a good abstraction for interactive rebase. It provides a drag-and-drop UI with a dropdown to select actions applied to each commit. That is much easier than editing a text file. Here's a GIF I found with Google: https://yogwang.site/2025/cursor-vscode-gitlens-rebase-edito...

Oh that's really very clean, yeah. It's almost literally exactly what's in the text editor, just with a more friendly-for-mouse UX. They did very well.
Post reply on HN