8 comments

  • roelschroeven1 hour ago
    &gt; 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.<p>It now has 5 upvotes. A long way to go to 2656 but at least it&#x27;s going in the right direction.
    • no-name-here10 minutes ago
      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.
    • hotelsacher1 hour ago
      Still, it shows how incredibly broken the StackOverflow system is. It&#x27;s completely normal for older answers to become outdated, but they still act like the old answers are laws of nature.
      • BeetleB32 minutes ago
        I think this is harsh criticism. It&#x27;s because not many people use SO any more.<p>One of SO&#x27;s selling points was that outdated answers get replaced with the more modern, better ones - and it worked for many, many years.
  • ivanjermakov1 hour ago
    StackOverflow is really not great at handling questions for which the right answer changes over time. I guess it doesn&#x27;t matter since SO is dead anyway: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=46482345">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=46482345</a>
  • diath55 minutes ago
    That&#x27;s good to know, I&#x27;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.
    • qsera8 minutes ago
      I do the same, but use `git gui` to select the changes.
  • ajasmin43 minutes ago
    Love the minimalist blog layout
  • matheusmoreira50 minutes ago
    Today I learned about git history split. Thanks!!
  • BeetleB33 minutes ago
    Is this yet another case of git improving its UI due to jujutsu?<p>(This is exactly how jj does it.)<p>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&#x27;t bother with in git, but routinely do in jj.<p>jj has fewer commands than git, yet does everything git does.
  • furkanturan3 days ago
    I never thought about whether this was possible, but now that I know it is, I immediately see how useful it could be for my workflow.
    • jaltekruse1 hour ago
      I had a team that insisted on a linear history and was constantly rebasing things. This workflow strongly favors &quot;just squash it all together&quot; 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&#x27;s just second nature to review my own changes every time I stage files and quickly do a mix of staging whole files or &quot;hunk-based&quot;, even allowing clicking to select specific lines within a hunk intuitively, rather than using the terminal UI and asking git to take a guess at splitting a hunk. I find a good git GUI invaluable, I have used sourcetree for years and love it. Unfortunately sourcetree isn&#x27;t available for Linux, but I recently found SourceGit which seems to be a decent substitute.<p>Highly recommend trying a good GUI out, I think you would likely have similar ah-ha moments about workflow optimizations, and honestly I just cannot understand how people get by in git without a convenient way to visualize the commit tree (and yeah I know there is a decent command line treeview, but the context switching all the time in the terminal to go from viewing the tree or even the simple log to exit out and ask for commit contents just is so much more fussy and tedious).
      • farlight53 minutes ago
        git rerere will resolve repeated conflicts for you automatically, you just need to enable it.<p><a href="https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-rerere" rel="nofollow">https:&#x2F;&#x2F;git-scm.com&#x2F;docs&#x2F;git-rerere</a>
      • esafak1 hour ago
        <a href="https:&#x2F;&#x2F;github.com&#x2F;DetachHead&#x2F;rebased" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;DetachHead&#x2F;rebased</a>
  • svyatoslavpavl59 minutes ago
    The bit that made this click for me: it works on any commit in history, not just HEAD. Mark the commit as edit in git rebase -i, then git reset HEAD^ to uncommit it while keeping the changes in the working tree, and rebuild the pieces from there.<p>git add -p is the real workhorse for the rebuild: s splits a hunk into smaller ones, and e lets you hand-edit the hunk when the boundary doesn&#x27;t fall on clean line breaks. Stage a coherent slice, git commit, repeat until the tree is empty, then git rebase --continue. The rebase&#x27;s only job is to drop you at the right spot; add -p does the actual splitting.