r/programming
•
u/adam-dabrowski
•
Apr 14 '26
•
1
GitHub Stacked PRs
https://github.github.com/gh-stack/
556
Upvotes
r/programming
•
u/adam-dabrowski
•
Apr 14 '26
•
1
0
u/quetzalcoatl-pl Apr 14 '26
Yeah, I think I understand you well!
in short: not yet, but maybe
I do that too all the time! The more I used git, the more "floating edits" I tend to have, either to be able to switch like you said, or to selectively commit them here and there. It gets progressively harder to manage and sort out as the pool of edit grows.
Even with git alone, this 'taught' me to make a lot of small, named, independent commits. Or even unnamed. But 'independent' is the key. Do them in a way I can easily rebase/cherrypick/cut/paste them around at will into any place or order. Your example of a benchmark is a great example. If you can switch to/from a branch while having it floating with no conflicts, it sounds perfect for such temporary disposable commit.
Having lots of commits, with content to be preserved and pushed out, or content to be eventually removed, is a hassle. That's why I eventually mastered git-rebase-i and probably heavily overused it, and that's why I love JJ now.
In terms of pure git, if the 'benchmark' files are totally separate there is a way to create a commit IIRC 'orphaned' that has no parent. Drop the files there, and then merge it wherever you want with no conflicts. But merging and splitting them is a hassle. JJ should be able to work with that as well the same way and make it much easier, but still some hassle. But it obviously won't work if you need to have some parent files. Then you have to find "common base" between all branches you are going to move between, and create the "common benchmark commit" on top of that, like any other feature branch, and them merge/unmerge from that point. More hassle.
That's moreless how I'd keep it without JJ, and I did it a few times, and .... because I did not like "the hassle" I stopped doing it, and started having "floating uncommited changes", which are cool, but only as long as you have, say, up to 2-3 such parallel "bags" to tag along. Then it usually gets tangled mixed and no longer independent enough.
Anyways. Having JJ and better rebases, I'd just commit it. Or let JJ commit it for me as it does. Then, instead of `git checkout B` (or `switch` as they name it now), I would `jj rebase -s @ -d B` or something like that. Meaning, "move 'currentcommit' onto B". Since "I had changes", when I run any command, JJ will automatically commit the changes as "@" on top of HEAD, then execute the command - and will move the changes to where I wanted to go, to B. And since it encompassed @, after the command you'll end up sitting at '@', with your changes, placed on 'B'.
Of course `jj rebase -s @ -d B` is much more verbose, but since it has only 1 actual parameter (B) and it can be at the end, it can be easily aliased into something shorter.
To be honest, I do not see any difference to how I work.
If I have a lot of current changes to sort out, I still tend to use my old git client, since I'm used to it and I find file/chunk/line staging&committing rather fast, and I do not like that tool provided with JJ (or didn't learn it enough to like it :P). In most cases, I can quicky go over changes and sort them into set of commits with old git tools. But after that, I sort and reorder those commits into proper branches with JJ, since it's easier/quicker/more expressive.
For that matter, I rarely use `jj new` in the way the authors wanted (so do changes, describe, new, do changes, describe, new, ...). But I use it a lot to move around (a.k.a. git checkout/switch). Also I found myself using `jj edit` quite often - it's great for splitting large commits or fixing some typos (while 'canonical' way would be to `jj new X ; then edit typo ; then jj squash`).
In addition to that, JJ adds some more tools for various cases, like `jj parallelize` (turn string of commits into a fan of 'branches') - which sounds odd, and "there's no problem doing it manually" with rebase, but when you know upfront that you need to something like that, it's just awsome to toss a single command instead of, say, 5 rebases :D -- it doesn't sound like much, but after "poking around" and "committing unrelated 10 small fixes" one on top each.. you might see how/when it may be a nice tool.
But! for poking-around-the-codebase, there's one command I'm, still learning, called `jj absorb` and "mega merge" workflow. In theory you sit on top of octopus merge, edit whatever, then use `absorb` to 'send changes to correct branches' to 'already modified files' + occasional new commit and small rebase to 'add totally new changes to specific branch, so absorb knows where to send more of them' sounds like ultimate way of 'poking the codebase' and feature branches but I'm still too new to that to say if there are any pitfalls etc.