5 ms·
A better merge workflow with Jujutsu
- chasinglogic 2y ago> Using Jujutsu, “amending a commit” also produces a new commit object, as in Git, but the new commit has the same change ID as the original. This is confusing to me, though to be fair I'm a "git expert" by trade. If you're amending a commit surely the "change" has changed so the change ID should also change? If the "change" isn't tracking the actual changes then what could it be tracking? Overall I think this is just more confusing than using git but I think it's cool that people are building alternative clients. That's definitely the way to go if you want adoption. Making history manipulation easier seems like a bit of a recipe for disaster given my experience training people. That old XKCD about git comes to mind and honestly that's where most people stay, if you bother to learn it then things like Jujitsu are probably harder to use for you. If you aren't interested in learning git to that level then I doubt you want / need something like Jujitsu. For those curious the "multiple branches" at a time thing they're selling can be done with git, IMO easily, using worktrees: https://git-scm.com/docs/git-worktree https://git-scm.com/docs/git-worktree
- fragmede 2y agoworktrees are pretty great but they make some things a bit more complicated conceptually compared to just checking out two copies for some people
- FranGro78 2y agoI’ve also run into problems with tools that aren’t worktree aware so often that I’ve stopped using it. I’ve been using jujutsu for about 6 months now, and the only time I’ve reached back for git was when I had to rebase and amend someone else’s branch to get it merged (when they weren’t available to do so themselves of course). Switching between changes in jujutsu has been a pleasant experience for me thus far, although I’m not as good with it as I was with stacked-git to keep local only changes (things I’m hacking to match my workflow / local setup) out of change sets. The way it displays diffs is also still something I am getting used to, and have made plenty of mistakes when pulling in changes from trunk. That’s probably more of a case of “old dog new tricks” than jujutsu.
- KingMob 2y agoYeah, after the first month of jj, I abandoned git forever, because it's already so much better. There are some hiccups, though. I switched over to colocation for all repos, because too many things expect git directories to be where they expect. I think the revset language is cool and powerful, but if I'm honest, it's tempting me to spend too much time trying to master, when 99% of the time all I need is, "show me the nearby ancestors and descendants within k revisions". I think the diffs need work. Or I need to get comfy with 3-way diffs. It's unfamiliar, and an obstacle to fixing conflicts. Luckily I get maybe 1/10th the conflicts I used to under git.
- Zambyte 2y ago> I think the revset language is cool and powerful, but if I'm honest, it's tempting me to spend too much time trying to master, when 99% of the time all I need is, "show me the nearby ancestors and descendants within k revisions". I just spend enough time to write a new function for what I want to do, and then just know the basics for regular day to day stuff. I feel like that gets me really far.
- KingMob 2y agoYeah, I've done that as well. I wonder if the revset docs should be split into "Basic" and "Advanced" sections.
- OJFord 2y ago> I think the diffs need work. Or I need to get comfy with 3-way diffs. It's unfamiliar, and an obstacle to fixing conflicts. You should get comfy, you won't regret it. I haven't got around to trying jj yet, but I use them in git; frequently see people messing things up or just having a hard time resolving a conflict that they wouldn't if they used (& understood) diff3. In brief: a regular 2-way diff shows you the current state, and what you wanted to change to right? Well 3-way just adds an extra bit of information (the middle) which shows you from what state you were changing to the bottom. So say you have: <<<<<< HEAD def wazzle(widget): try: widget.wazzle() except Exception: return False return True ||||||| def wazzle(widget): widget.wazzle() ======= def wazzle(widget): from wazzler import wazzle wazzle(widget) >>>>>>> (deadbeef Abstract wazzle implementation to own package) If you didn't have the middle, it might not be at all clear why you were getting the conflict, and what the appropriate fix is. It allows you to see that Ah ok, master (or whatever I'm rebasing on or whatever) has changed to return a bool indicating success or error, that's fine, I was just trying to change the wazzle method to pass it to a library function instead. Or you might have it that the same change is already in the HEAD part at the top, but there's a conflict because they put the import elsewhere. The middle then allows you to see that you were making essentially the same change, you don't care where the import goes (or like their idea better), you can just remove it and stick with the changes on HEAD. My point is that it's strictly more information, that can help or make it easier to resolve the conflict. It shouldn't be confusing at all, because the same 2-part thing you're accustomed to is there too.
- KingMob 2y ago> If you're amending a commit surely the "change" has changed so the change ID should also change? If the "change" isn't tracking the actual changes then what could it be tracking? The author is using newer terminology around "changes", but I prefer the older "revisions", as being less overloaded. But yes, the revision/change ID remains the same even if the commits underneath changes. `jj obslog` will show you the history of commits underlying a revision. This stability is what we want when rebasing, and git doesn't provide it. > Making history manipulation easier seems like a bit of a recipe for disaster ... I used to think this too, but it was really due to git and its CLI. Under jj, history manipulation is easy, consistent, and easily reversible with `jj undo`. Because it's safer and easier, I routinely do way more rebasing, and stacked PRs are much less painful to incorporate feedback on. Basically, it makes git's more advanced operations feel like everyday tools. (Of course, jj doesn't fix the problem of rewriting history that's already been shared with other people, but even there, its notion of immutable commits tries to stop you from breaking other people's histories.) > the "multiple branches" at a time thing they're selling can be done with git, IMO easily, using worktrees Worktrees aren't quite the same thing the author is describing. Worktrees allow you to check out multiple branches at the same time to different directories, but they're still sort of separate. The author is making the working revision a merge revision where every parent is a branch they want to work on. This allows them to see what the code will do when those branches are merged. They can also add revisions to all branches simultaneously by working on the merge rev, and using `jj squash` to choose which parent branch to push work to on the fly. When done for the day, `jj abandon` the merge commit. AFAICT, it's both lighter and more flexible than worktrees.
- epage 2y agoimo revision is worse. I feel like the best terms are patch id and patch revision id.
- 0cf8612b2e1e 2y agoI am sad I read this, because patch is perfect, but I doubt they will change the language again.
- kstenerud 2y agoThink of the change ID as a "symbolic name", as opposed to the commit ID which identifies a particular snapshot. As you amend a commit, it creates a new commit ID each time. Only the commit ID of the most recent amendment is in your final graph. All the old ones are orphaned for garbage collection. The change ID never changes as you make amendments (because you're still working on the same change), and this change ID will always be in the graph. So you can refer to the change ID (which doesn't change) instead of the commit ID (which changes with every amendment). Another way to think of it would be akin to filenames vs inodes in a filesystem (it's not 100% the same, but the concept should help you visualize). If you delete a file and create another one with the same name, its filename will be the same, but its inode number will be different because it's technically a different file. The old inode gets marked deleted so that it can be reaped somehow. If you make a symbolic link to the file, you'll always get the intended one (because a symbolic link refers to a path). If you make a hard link to the file, you'll get an outdated file after something replaces it (because a hard link refers to an inode).
- Zambyte 2y agoOthers have explained the change IDs already in detail, but I want to try to give a short and sweet explanation: changes in Jujutsu are a mutable, high level abstraction built on gits immutable commits. Change IDs are stable across mutations.
- michelledepeil 2y agoTIL about worktrees, a feature I've needed in the past but didn't expect to even exist.
- steveklabnik 2y agoJj also supports worktrees, though they call them workspaces.
- stouset 2y agoThere’s still a git-compatible commit ID which changes along with the contents. There’s also an immutable revision/change identifier that persists even as you continue working on it. This works extremely well in practice and makes rebase-heavy workflows practical even when collaborating with others.
- 0cf8612b2e1e 2y ago…can be done with git, IMO easily, using worktrees Like many things in git, the capability exists, but I would not call worktrees easy. The few times I have tried to play with worktrees resulted in enough friction that it felt safer to use a clone in a separate directory.
- deleted 2y ago[deleted]
- aranw 2y agoI really like the idea of Jujutsu and was really keen to try it out but when I looked at it several months back I found it really hard to get going with it and ended up just ditching it. This article looks to be a explanation to some of the concepts of `jj` and how to use it in a little more depth than some of the other tutorials I have seen out there. Definitely keen to give it another try at some point
- christianPerdu 2y agoSame here, exact same here !
- stouset 2y agoOn the flip side, I expected it to be a bigger migration than it was. But I was using it effectively as a complete git replacement the very first day. I still had a few things I didn’t know how to do optimally, but it was close enough to be productive. Within a week I’d closed basically all of the gaps. It’s been three or so months and I’m never going back. It’s been so transformative I can barely remember all the innumerable frustrations and papercuts I used to put up with daily. Rebase conflicts. Juggling the stash. Ugh. I say this as someone who considered themselves extremely proficient with git. I mean, I wrote a compatible Ruby implementation of it over a decade and ago. If it gains momentum, jj has a better chance than anything I’ve seen at finally dethroning git.
- rkangel 2y ago"New VCS, but Git is a first-class backend" is an amazingly smart decision. It's the only chance you actually have of supplanting git. It's a new VCS with enough workflow benefit to be worth making a user switch (in contrast to most git alternate command lines) but provides an easy migration path where you don't have to make a "whole repository" decision. It's an individual engineer decision, that still allows using your existing servers (Github/lab).
- stevage 2y agoAll these things just remind me how depressing it is that we all use this deeply flawed tool, git, and no one can get enough critical mass for a substantially better version.
- whoomp12342 2y agohumans are creatures of habit. fixing these flaws is not enough to motivate us onto something new, it has to be groundbreaking.
- g-b-r 2y agoIt's not a matter of habit but of widespread usage If you're a developer, for almost every job or open source job you'll be required to use git, but I think most people long of moving away from it
- jeltz 2y agoNot my experience at all. Most devs I have met in real life love git. It is certainly not perfect but it is good and way better than what came before. I would be happy if someone wrote a replacement which improved substantially upon git but if that never happens that would be fine too.
- g-b-r 2y agoWell not my experience, but yeah let's hope that something much better replaces it soon
- jFriedensreich 2y agoyou can start using sapling today. its github compatible and production ready. as long as the new tools support github or whatever forge/hub you are using, there is no need for critical mass for adoption. This is not possisble for radical approaches like pijul, but that approach is not fully proven yet.
- whoomp12342 2y agothe core issue with GIT is this: it requires cognitive overhead. JJ doesn't seem to solve that.
- steveklabnik 2y agoCan you say more? I find jj to be easier to reason about, but that’s not the same thing.
- stouset 2y agoHaving used both, jj imposes dramatically less cognitive overhead. I was (am?) a git expert and power user. In a month I began trusting jj to a level I never did after using git shortly after its first official releases. I “blindly” undertake repo changes that I’d double or triple check before doing in git. It’s better to a degree I never would have believed before I gave it a shot.
- KingMob 2y agoI would say it's about the same. jj adds some concepts, like change/revisions and revsets, but it also has lower cognitive load than git on things like branches, the index, and the CLI. The ease of undoing anything alone makes it way easier to learn jj, since you can be fearless. It's not quite clear to me how much simpler DVCS concepts can be.
- simonmic 2y agoAre Jujutsu users all using it from the command line ? Is there anything magit-like yet ? Or do you use magit with it ? Have you run into extra complexity and messes because of having two VCSes interacting in one working copy ?
- steveklabnik 2y agoMost are using it from the command line, but https://github.com/gulbanana/gg https://github.com/gulbanana/gg is an in-progress GUI. I don't use collocated repositories, so I can't speak to your second question, but I rarely hear people complain about it on their Discord.
- simonmic 2y agoVery nice, thank you!
- gpm 2y agoI'm an extremely light user (just on a few small projects), but > Have you run into extra complexity and messes because of having two VCSes interacting in one working copy ? Well, making git commits in a colocated jujutsu repository was a very confusing experience, because at some point I realized I wasn't on a git branch like I thought I was (after a few commits!). jj somehow magically did the right thing though and after switching back to it I had the commits I tried to make in jj and they worked just fine.
- CraftThatBlock 2y agoI am (slowly) working on a TUI: https://github.com/Cretezy/lazyjj https://github.com/Cretezy/lazyjj
- simonmic 2y agoAlso nice, thanks!
- KingMob 2y ago> Are Jujutsu users all using it from the command line ? Yes. Even with no UIs or editor support, it's already a better experience than git for me. > Have you run into extra complexity and messes because of having two VCSes interacting in one working copy ? For tools that expect git, you can assist them by using a colocated repository, so they can still see git. It works well enough, though most of the time, they will think you're on a detached HEAD. That being said, I avoid git's mutating operations. I've heard that can cause trouble.
- dang 2y agoRelated: GG, a GUI for Jujutsu - https://news.ycombinator.com/item?id=39713896 https://news.ycombinator.com/item?id=39713896 - March 2024 (2 comments) jj init – getting serious about replacing Git with Jujutsu - https://news.ycombinator.com/item?id=39232456 https://news.ycombinator.com/item?id=39232456 - Feb 2024 (110 comments) Jujutsu: A Git-compatible DVCS that is both simple and powerful - https://news.ycombinator.com/item?id=36952796 https://news.ycombinator.com/item?id=36952796 - Aug 2023 (261 comments) Jujutsu: A Git-compatible DVCS that is both simple and powerful - https://news.ycombinator.com/item?id=36371138 https://news.ycombinator.com/item?id=36371138 - June 2023 (1 comment) Jujutsu – A Git-compatible DVCS that is both simple and powerful - https://news.ycombinator.com/item?id=30398662 https://news.ycombinator.com/item?id=30398662 - Feb 2022 (228 comments)
- xlii 2y agoI really tried to like jj but I couldn’t make it work for my workflow: There are files that are committed to repository that I need to edit (e.g. .envrc files, which cannot be overridden). There is no way I can ignore those in Jujutsu. In plain git I can do sparse checkout using negative paths and it works. jj doesn’t support it, and using positive path doesn’t work as I never know if new files are there. Every push was a dance around removing my changes. I’m checking if there’s progress from time to time but there’s no so far. But just yesterday I decided to check git branchless as I’m exploring stacked PR workflow and I can say it’s intriguing and even if more rough around the edges than jj I haven’t yet found any showstoppers.
- arccy 2y agocan't you just add them to gitignore? if you want it to be local only, there's also .git/info/exclude or for all your repos with ~/.config/git/ignore
- Ambroisie 2y agoI think OOP meant to say that the `.envrc` file _is_ committed, but they want to do local changes _without_ the possibility of them getting accidentally committed by mistake.
- arccy 2y agothe simple workaround would be to have .envrc optionally load another gitignored file if it exists, which sounds much safer than accidentally committing local changes, even with plain git.
- bbkane 2y agoIf that's not possible, maybe OP can rename it to .envrc.example, and commit that. Then put in the instructions to rename .envrc.example to .envrc on checkout
- 2y ago
- gocartStatue 2y agoA better way for suboptimal workflow to begin with („multitasking” on branches)?
- knallfrosch 2y agoIsn't that what git worktrees solved and noone knows about?
- dolmen 2y agoI have lot of old local Git branches. Most were pushed on the central server. The central server also have some old branches. Some local branches have been rebased locally. Some have been rebased on the server. Some have been merged on the server (with rebase or not). I need to clean-up both my local clone and the central server from the branches which contain changes that have been fully merged Can Jujutsu help with that task? If not, any other solution?
- stouset 2y agoYes, almost certainly. Jujutsu has an embedded mini-language to specify revsets. It’s not too hard to make a revset for “all branch names that are descendants of trunk (main/master)”. You can feed this directly into `jj branch delete`, which will remove your local copy of each branch and flag them for removal from the remote during the next `jj git push`.
- sea-gold 2y agoA tool such as git-delete-merged-branches[1] may also be helpful. [1]: https://github.com/hartwork/git-delete-merged-branches https://github.com/hartwork/git-delete-merged-branches
- technojamin 2y agoJujutsu seems really cool, and I love that I can use it in a Git repository alongside other contributors that don't. It seems like a lot of logging features from Git aren't present, though. Besides the mentioned lack of blame functionality[1], things like path filtering (`git log -- <PATH>`), file-following with rename detection (`git log --follow -- <FILE>`), pickaxe (`git log -S <CODE>`), and range evolution (`git log -L<START>,<END>:<FILE>`) are missing. These tools have all become pretty indispensable to me in my day-to-day work since I've learned them, and I know I can still use them since jj can use Git as a backend, but I don't think I could adopt a tool that doesn't have them as first-class features. Do any regular users of Jujutsu have thoughts on this? [1] https://github.com/martinvonz/jj?tab=readme-ov-file#status https://github.com/martinvonz/jj?tab=readme-ov-file#status
- kubanczyk 2y ago> These tools have all become pretty indispensable to me in my day-to-day work How much indispensable, in dollars?
- technojamin 2y agoWhat? That's a weirdly money-minded question. I'm not gonna do some Google interview-esque estimation question to answer that, but I'll elaborate on how I use those features, because I enjoy discussing them. I use line range history the most, multiple times per day, since it's a much better alternative to line blame in most situations. You get the full historical context of a line instead of just the last commit. File blame is really useful when I'm encountering new code, and I want to quickly find out who has the most "responsibility" over it, oftentimes so I can go and ask them about it if I need more clarification. File history is especially useful when I come back to a file that I originally wrote or was familiar with, some time has passed, and now I want to re-familiarize myself with all the changes since the last time I was familiar (could be years). Rename detection is useful when there are repository-wide restructures, which has happened a couple of time in the main repository I work on. Otherwise, your history will cut off at that refactor, which is really irritating. I use path history like file history, but to re-familiarize myself with large modules (admittedly less often than file history, but it comes up). I'm newer to pickaxe, but I've used it 2 or 3 times in the past year to track some chunks of code throughout a refactor. That's how a lot of these little tools that Git has work. You might only use them a few times per year, but when you need them, they're really amazing. It seems like Jujutsu focuses a lot on the commit authoring and modification flows, and it looks like it offers improvements in those areas, but I don't see much functionality in the history investigation area. They might be considered niche features to some, but I think this functionality becomes more valuable the older and larger a codebase gets.
- OJFord 2y agoThis is essentially GitButler's 'integration branch' idea, but via CLI. I tried it briefly, found it frustrating to use a GUI and not helped by (it's early days) bugs. It occurred to me I could just do the same 'manually' or with some git aliases to help, but I haven't, and I'm glad I've seen this (and the reminder to try out jj in general) because it's certainly far nearer than it would be in pure git.