Live data from Hacker News

Splitting a Git Commit

blog.gnoack.org

11–20 of 74 posts

Re: Splitting a Git Commit

#13
Is this yet another case of git improving its UI due to jujutsu?

(This is exactly how jj does it.)

If you like this kind of convenient CLI command, I would seriously recommend giving jj a try. To give you an idea, I never bothered splitting a commit in my git days. I do it almost daily with jj. Lots of other niceties that I didn't bother with in git, but routinely do in jj.

jj has fewer commands than git, yet does everything git does.

Re: Splitting a Git Commit

#14

> P.S. The stack overflow question for splitting commits discusses the old and cumbersome approach. The 20th answer discusses the right approach but has a meagre 2 upvotes as of today, compared to 2656 for the older top answer with the cumbersome approach. It now has 5 upvotes. A long way to go to 2656 but at least it's going in the right direction.

Still, it shows how incredibly broken the StackOverflow system is. It's completely normal for older answers to become outdated, but they still act like the old answers are laws of nature.

I think this is harsh criticism. It's because not many people use SO any more.

One of SO's selling points was that outdated answers get replaced with the more modern, better ones - and it worked for many, many years.

Re: Splitting a Git Commit

#15

Earlier quoted context omitted.

I had a team that insisted on a linear history and was constantly rebasing things. This workflow strongly favors "just squash it all together" before a rebase to avoid re-resolving the same conflicts. This workflow often produces big patches that reviewers end up asking to be broken back up. This experience and a recommendation from my manager at the time made a good git GUI like sourcetree a daily driver for me. It'…

git rerere will resolve repeated conflicts for you automatically, you just need to enable it. https://git-scm.com/docs/git-rerere

[dead]

Re: Splitting a Git Commit

#16

> P.S. The stack overflow question for splitting commits discusses the old and cumbersome approach. The 20th answer discusses the right approach but has a meagre 2 upvotes as of today, compared to 2656 for the older top answer with the cumbersome approach. It now has 5 upvotes. A long way to go to 2656 but at least it's going in the right direction.

It’s now the 6th answer instead of the 20th, and if answers are sorted by Trending (which I recommend people do) in the dropdown, it’s currently 3rd.

Re: Splitting a Git Commit

#17
post #9

That's good to know, I'd usually go about it in a roundabout way: soft reset the commit then git add --patch to stage the hunks to split it into multiple commits.

I do the same, but use `git gui` to select the changes.

Re: Splitting a Git Commit

#18

> P.S. The stack overflow question for splitting commits discusses the old and cumbersome approach. The 20th answer discusses the right approach but has a meagre 2 upvotes as of today, compared to 2656 for the older top answer with the cumbersome approach. It now has 5 upvotes. A long way to go to 2656 but at least it's going in the right direction.

Still, it shows how incredibly broken the StackOverflow system is. It's completely normal for older answers to become outdated, but they still act like the old answers are laws of nature.

At least the answer is there. When asking ChatGPT (Plus) the same question, it only suggests the old ways.

Re: Splitting a Git Commit

#19
post #17
post #9

That's good to know, I'd usually go about it in a roundabout way: soft reset the commit then git add --patch to stage the hunks to split it into multiple commits.

I do the same, but use `git gui` to select the changes.

Which gui? I’m on Mac and somehow I could never really be happy with gui‘s for git. Gitkraken is the last I tried and I found it too much cluttering. Paid choices weren’t that great aswell either (yet)

Re: Splitting a Git Commit

#20
post #14

Earlier quoted context omitted.

Still, it shows how incredibly broken the StackOverflow system is. It's completely normal for older answers to become outdated, but they still act like the old answers are laws of nature.

I think this is harsh criticism. It's because not many people use SO any more. One of SO's selling points was that outdated answers get replaced with the more modern, better ones - and it worked for many, many years.

... until they decided it was a good idea to train all power users to grief new users off the site.
Post reply on HN