Live data from Hacker News

Git Rebase for the Terrified

brethorsting.com

241–250 of 305 posts

Re: Git Rebase for the Terrified

#241

Earlier quoted context omitted.

Doesn’t that mean you have to fix all the merge conflicts introduced by your commits on every rebase though?

Git has gotten pretty smart about that recently: once you resolve a conflict, if you get the same conflict again it automatically resolves it the same way. Works for both rebase and merge.

[deleted]

Re: Git Rebase for the Terrified

#242

Earlier quoted context omitted.

>each commit nominally should work Except it can be the result of 10 squashed commits.

Which is the entire point of it. Why should I look at ten commits when I can look at one and get the same exact data? Why should I pollute my production history for what a is likely a bunch of debugging commits? The branch is a scratchpad, you should feel empowered within your own branch, rebase allows you to be lazy in the development cycle while presenting a nice clean set of changes at the end of it.

Yes! When you are deep in the code, your brain operates in a non-linear way. You try a solution, it breaks a test. You patch the test. You realize the variable name is wrong. You fix a typo.

Without Squash, the main branch history becomes a timeline of your mental struggle.

With Squash, the main branch becomes a catalog of features delivered.

No body needs to take a trip on the struggle bus with me...

Re: Git Rebase for the Terrified

#243
post #11

Allow me (today) to be that person to propose checking out Jujutsu instead [0]. Not only it has a superpower of atomic commits (reviewers will love you, peers will hate 8 small PRs that are chained together ;-)) but it's also more consistent than git and works perfectly well as a drop-in replacement. In fact, I've been using Jujutsu for ~2 years as a drop-in and nobody complained (outside of the 8 small PRs chained t…

I'm a big fan of rebasing to keep the commit history clean and as a form of self-discipline when coding to make sure I'm grouping the changes atomically.

I will try to give Jujutsu a go based on your recommendation!

Re: Git Rebase for the Terrified

#245
One thing I still love about blogs like this that AI can never replace is that it takes a topic that might seem complicated to some people such as myself (Git Rebase does actually terrify me) and it talks about it in great detail in a way where I don't have to know what to ask. I don't have to prompt about something I don't even know where to begin. The topic is introduced and elaborated on while speaking to a general audience. So that's why I still like to see tech blogs out there.

Re: Git Rebase for the Terrified

#246
I also get tons of mileage out of This One Weird Trick: make a new branch first. Every single time it appears non-trivial, just abort and branch before continuing.

Then if you screw up, even several steps later when it's hard to un-rebase a portion, you just go back to the original. No need to dig through the ever-confusing reflog format, just use branches. For really gnarly ones, it also means you can early compare the two diffs to see if you missed anything.

Once you're fully happy with it, you can push that new one, or just go back to your original and `git reset --hard after-rebase-branch` to adopt the new history.

Re: Git Rebase for the Terrified

#247

PSA: I’m not terrified of rebase, yet it’s good to know this: https://docs.github.com/en/get-started/using-git/about-git-r... > Warning - Because changing your commit history can make things difficult for everyone else using the repository, it's considered bad practice to rebase commits when you've already pushed to a repository. A similar warning is in Atlassian docs.

[deleted]

Re: Git Rebase for the Terrified

#248
post #246

I also get tons of mileage out of This One Weird Trick: make a new branch first. Every single time it appears non-trivial, just abort and branch before continuing. Then if you screw up, even several steps later when it's hard to un-rebase a portion, you just go back to the original . No need to dig through the ever-confusing reflog format, just use branches. For really gnarly ones, it also means you can early compare…

I do this, and with TortoiseGit I just pick and choose the good bits and put them as atomic changes in their own branches and PRs.

Re: Git Rebase for the Terrified

#249

Earlier quoted context omitted.

Squash merges are a hacky solution to the git bisect problem that was solved correctly by --first-parent 20 years ago. There are fully employed software developers working on important stuff that literally were never alive in a world where squash merges were needed. Don't erase history. Branch to a feature branch, develop in as many commits as you need, then merge to main, always creating a merge commit. Oftentimes,…

Using git history as documentation is hacky. A majority of feature branch commit messages aren't useful ("fix test case X", "fix typo", etc), especially when you are accepting external contributions. IF I wanted to use git history as a form of documentation (I don't. I want real documentation pages), I'd want the history curated into meaningful commits with descriptive commit messages, and squash merging is a great w…

As far as I'm concerned, the git history of a project is the root source of truth of why a change was made, at that point in time. External documentation is mostly broad strokes, API references, or out of date. Code comments need to be git blamed anyway to figure out when they were added, and probably don't exist for every little change. Pull requests associated with a given commit give the broad description of "what feature was being implemented or bug was being fixed" for a given change, but a commit message tells me what, specifically, during that work, triggered this particular change. I want to know, for example, that the reason this url gets a random value appended to it is that while implementing a new page to the site it was found that the caching service would serve out-of date versions of some iframe. It never made it out of dev testing, so it never became a full-blown bug, it wasn't the purpose of the feature branch, so it wasn't discussed in the PR. But the commit message of "Add some cache-busting to iframe" (even something that brief), can go wonders to explaining why some oddity exists.

Re: Git Rebase for the Terrified

#250

I have been contributing code for 10+ years, and I have worked on teams that did rebase and others that did not. Not once have a ever debugged a problem that benefited from rebase vs merge. Fundamentally, I do not debug off git history. Not once has git history helped debug outside of looking at the blame + offending PR and diff. Can someone tell me when they were fixing a problem and they were glad that they rebased…

> Fundamentally, I do not debug off git history.

I'm really sorry. Using bisect and log -S saved hours of code debugging

Post reply on HN