4 ms·
One really nice trick you can do is: - Create multiple topic branches, one for each thing you're working on. - Now you probably want to work on item A while h
by Filligree 1y ago
One really nice trick you can do is:
- Create multiple topic branches, one for each thing you're working on.
- Now you probably want to work on item A while having B and C all available, so make a single merge commit (jj new a b c) to build on top of.
- Create further commits on top of that, while you're working.
- When you're cleaning up (ideally often), use squash --to or rebase --after to move those commits back the branch they belong on. This does not invalidate the merge commit; you will, effectively, have multiple branches checked out at once.
EDIT: This is apparently called the 'megamerge workflow'.
- icorbrey 1y agoMegamerges are awesome, but what really makes them magical is when you start using `jj absorb`, which automatically splits and squashes your commit down to the nearest unambiguous commits and leaves anything that doesn't have an obvious place to live
- nchmy 1y agoI've been trying absorb recently and have found it rarely does anything and I just resort to squashes. Any idea what might be going on?
- Filligree 1y agoAbsorb: - Will not rewrite an immutable commit, of course. (Though you can tell it to, and for my personal repositories I sometimes actually set immutable() = root().) - Will not do anything to diffs if it's uncertain where they should go, either because that file wasn't edited in a previous mutable commit, or because it was edited in multiple sibling/cousin commits. The latter is likely to happen with mega-merges. You can use --into to restrict the set of target commits, if you already know what feature branch you're updating.
- nchmy 1y agoYeah, I was already aware of megamerge. I use it. But I'm still not disciplined enough to use it and other proper workflows consistently, especially when new features/topics spring up while working on another one. I just start working on it at the same time, and jj makes it simple to split it into its own commit and branch later.