Hacker News new | past | comments | ask | show | jobs | submit login

> It combines features from Git (data model, speed), Mercurial (anonymous branching, simple CLI free from "the index", revsets, powerful history-rewriting), and Pijul/Darcs (first-class conflicts), with features not found in either of them (working-copy-as-a-commit, undo functionality, automatic rebase, safe replication via rsync, Dropbox, or distributed file system).

You lost me at "free from the index". The index is one of the most important parts of Git that makes my life easier. Opinionated DVCS UIs make my life harder -- all of them.

> The working copy is automatically committed

Right, so, the reason the index is powerful is that I get to do `git add -e`, `git commit`, and repeat until I'm done or ready to throw remaining changes away. I very much want the index / workspace distinction.

> Automatic rebase

> Comprehensive support for rewriting history

This is very welcome. At the very least this confirms something important: the fallacious argument that "rebase rewrites history, so it's eeeevil" is finally dead.




> You lost me at "free from the index".

If you click the link that text points you to (i.e. https://github.com/martinvonz/jj/blob/main/docs/git-comparis...), there's an explanation there for how to achieve the same workflows. I get that it's different, but I don't think it's worse. I consider myself a (former) git power user (I think I have ~90 patches in Git itself) and I've never missed the index since I switched to Mercurial ~7 years ago.

> This is very welcome.

Thanks :)


> With Jujutsu, you'd instead use jj split to split the working copy commit into two commits.

This is more confusing? Often times when debugging/writing a fix I would have extraneous code that I wouldn't want to commit. With an index I'm always sure if what I commit, but with this workflow you have to keep track of such stuff all the time and if you forget that stuff makes it in?

Not to mention that another benefit of an index is being able to change commits and git replaying your working diff.


yeah, i feel this is going to bother me, or at least be difficult to get used to.

i often have temporary files that i do not want to commit, nor do i want to add them to .gitignore (because i want to commit them later)

but then, i'll have to spend some time using jj split. if it is powerful enough then maybe the end result is just that those files only live in the last commit.

also, what happens on push? i'd never ever want the working copy to be pushed to the remote repo. i could not find anything in the documentation about that.

(according to the answer here: https://news.ycombinator.com/item?id=30399554 the working copy is not supposed to be pushed)


Yah... I have a long-standing habit of commenting `TODO` for some debugging or WIP code. Then, before I commit, I can just do `git diff | grep TODO` and see all the new TODOs I've added.


Something that’s backend compatible with Git but uses some of Mercurial’s sensibilities?

Sign me up!


https://hg-git.github.io/

Happy user for at least 6 years.

The sanity of Mercurial's UX cannot be overstated.


You cover `git add -p`, but I want `git add -e`.

Also, I often rebase and `edit` commits to split them or undo parts of them.

Rebase and all this is all about making commits that have just the right content, and keeping history clean and linear. The tools have to make this possible and easy.

I get that git feels... barebones for this. You really have to understand what you're doing when using git like I do, so I get that it's not very accessible.

Better UIs are great, but on the other hand, we need to be able to get down to the low level.

IMO.


> You cover `git add -p`, but I want `git add -e`.

Interesting. I don't think I've heard anyone use `git add -e` before. It should be easy to add that feature, but it would be very low priority since so few users seem to like to manually edit patches.

> Also, I often rebase and `edit` commits to split them or undo parts of them.

You can do that by checking out the commit, then `jj squash/amend` (aliases) and all descendants will be automatically rebased on top, and branches pointing to them will be updated too. There's also `jj edit` for editing the changes in a commit without updating to it. And there's `jj split` for splitting a commit (without needing to update to it).

> Rebase and all this is all about making commits that have just the right content, and keeping history clean and linear. The tools have to make this possible and easy.

Yes, that's definitely a goal. I think Jujutsu does a much better job at that than Git does. Did you read https://github.com/martinvonz/jj#comprehensive-support-for-r...?


I did, and it's almost certainly nicer than Git for commit splitting.

But even though I might use a tool specifically designed for user-friendly commit splitting, I still want: `git add -e`, `git diff --staged` (to see what I added with `git add -e`) vs `git diff` (to see what I left out), and `git commit` w/o `-a` to commit the contents of the index. This is easier for me than `$WHATEVER commit` followed by `$WHATEVER`'s commit splitting method.

That said, I have to congratulate you again on not taking the ugh-rebase-rewrites-history/history-rewrite-bad road. This is a huge step forward for DVCS.

It may well be that what rebase workflows needed was a UI that non-power users could use.

While we're at it, I wonder what you think of this: https://gist.github.com/nicowilliams/ea2fa2b445c2db50d2ee650...


That gist seems like a simplified version of https://github.com/mhagger/git-imerge, so check that out if you haven't. (I haven't looked at git-imerge in a long time, so I should read about it again myself.)


I'll take a look, thanks for the link!

EDIT: The idea of being able to suspend/resume and push/fetch in-progress merges/rebases is very cool indeed. It's hard to tell if it could speed up the task of rebasing across thousands of commits or not -- the README doesn't say. I like Viktor's script because it's very focused on one thing: quickly rebasing local commits across thousands of new upstream commits with a minimum of conflicts -- a simple solution to a simple problem statement (though the problem can feel huge when you have it).


I like and use the index in git too, but I wouldn't be so quick to dismiss other models that might end up solving the same use cases in a different way...

From the README, it looks like there's robust support for editing and splitting commits. So maybe in practice the flow is similar to using the index, with the added the added benefit that your work is backed via commits along the way, and the simplicity of not having the index as an extra concept.

In general when exvaluating X from the perspective of Y, we will immediately see the thing's about Y we like that X lacks; it takes more time to see if perhaps in the fuller context of X those things are not necessary.


The index is a power user feature. Its forced presence in Git effectively constitutes a usability barrier for new users. After all, a VCS is effectively a glorified abstraction for "save a file." Any barrier imposed between changing a file and committing it can get in the way and confuse people. The Git index does this.

Furthermore, the index is effectively a pseudo commit without a commit message. Any workflow using the index can be implemented in terms of actual commits itself.

I think because Git doesn't have strong usability in general and especially around history rewriting, many Git users feel that the index or an index equivalent is somehow a required feature of a VCS because Git's shortcomings give that illusion. However, if you use a VCS with better history rewriting (such as Mercurial with evolve), you'll likely come around to my opinion that the index can be jettisoned without meaningful loss of functionality or productivity.


I don't deny that the index is a power feature and that it's difficult to explain it to newbies.

Perhaps there's room for new UIs.

All I'm saying is I need this power. And it has to be easy to reach for it.


> Right, so, the reason the index is powerful is that I get to do `git add -e`, `git commit`, and repeat until I'm done or ready to throw remaining changes away.

You don’t need the index for that. In fact I’d say it gets in the way because the presence of the one means less pressure on improving the ability to edit commits: while it’s easy to add stuff to HEAD it’s much more painful to remove content from it.

If that is solved, then the value of the index drops precipitously, because you can create a commit with a purpose and select its content instead of having to do it the other way around then forgetting what change you were trying to craft.


If you can rewrite the history that actually got committed, do you really need a temporary pre-commit staging area?


The index is mostly useful to me to split a commit in multiple ones. You do that with a sequence of "git add -p" and "git commit" commands. I am interested in how to do this with jj, because otherwise it looks like a very interesting tool.


> I am interested in how to do this with jj

`jj split -r <commit>`, where `<commit>` may be the working copy commit (which is the default). See https://github.com/martinvonz/jj/blob/main/docs/git-comparis... for more examples.


so just for understanding: repeated `git add -p` followed by a `git commit` turns into repeated `jj split; jj squash`, since you create a commit each time?


That would work, yes, but there's also `jj squash -i` to move part of the child commit into the parent. There's also the more generic `jj move` command for moving part of any commit into any other commit (ancestor, descendant, sibling), so you `jj squash -i` is equivalent to `jj move -i --from @ --to @-` (where `@` is syntax for the working copy commit and `@-` is syntax for its parents).


I prefer "git stash -p" to exclude unfinished changes, because if I build up a partial commit in the index there’s no way to test it.


I do that later. I do `git rebase -i` and add `exec` lines to build each commit that must build.


> You do that with a sequence of "git add -p" and "git commit" commands.

You can do that with git commit -p.


True but there's usually a "git diff --staged" in the middle to check what I am committing.


You can do that with “git show HEAD” (and “git commit --amend -p”).


`git diff --staged` is superior. For one, you get all the options to `git diff`. For another, it has no side effects, unlike `git commit --amend -p`.


> `git diff --staged` is superior. For one, you get all the options to `git diff`.

Most of which you can get on git show at least if they're relevant to “what have I added”. And of course you can also use git diff on commits if you need something super specific.

> For another, it has no side effects, unlike `git commit --amend -p`.

… “git commit --amend -p” is the replacement for subsequent “git add -p”, as the GP was talking about a workfliw where they’d intersperse staging stuff and looking at what they’d staged.


Exactly!


`git add -e` is infinitely better.


Try git-crecord.


Yes, I do. I often do this (usually in detached HEAD mode!):

  : ; $EDITOR some-file ...
  : ; $build
  : ; git add -e # take a few chunks, maybe change them
  : ; git diff --staged; git status -uno
  : ; # lather, rinse, repeat
  : ; git commit -m '...' -ev
  : ; 
  : ; git status -uno; git diff
  : ; git add -e # ..
  : ; # lather, rinse, repeat until happy
  : ; 
  : ; git fetch origin
  : ; git rebase origin/master
  : ; # fix any conflicts
  : ; 
  : ; # continue until all bug fix / feature
  : ; # activity for this issue is complete
  : ;
  : ; # review my changes:
  : ; git log --patch origin/master..
  : ;
  : ; # if I have to clean my history a bit:
  : ; git rebase -i origin/master
  : ; # re-order commits, `edit` commits, `drop`
  : ; # commits as needed
  : ; $build
  : ; # fix remaining issues...
  : ; 
  : ; # finally ready to push:
  : ; git push myclone HEAD:refs/heads/this-thing
  : ; 
  : ; # open a PR
Repeat as needed to deal with code review comments until done and integrated.


Are you human?

> detached HEAD mode

Ah, I see, not anymore...


Lol, have an upvote!


> You lost me at "free from the index". The index is one of the most important parts of Git that makes my life easier. Opinionated DVCS UIs make my life harder -- all of them.

Mercurial has an 'index' / staging area, but not exposed by default. You can access it with some extra CLI options, but there is an optional idea that may be 'better' and worth looking into:

> If you need the index, you can gain its behavior (with many additional options) with mercurial queues [1] (MQ).[2] Simple addition of changes to the index can be imitated by just building up a commit with hg commit --amend (optionally with --secret, see phases [3]).

* https://www.mercurial-scm.org/wiki/GitConcepts#Git.27s_stagi...

[1] is "A Git User's Guide to Mercurial Queues"

* https://stevelosh.com/blog/2010/08/a-git-users-guide-to-merc...

MQs (optionally) expand on the idea of only a single staging area:

> This single "intermediate" area is where git stops. For many workflows it's enough, but if you want more power MQ has you covered.

> MQ is called Mercurial Queues for a reason. You can have more than one patch in your queue, which means you can have multiple "intermediate" areas if you need them.

If you only want to use one queue/index then that's fine too.


As a Mercurial user from almost the beginning, it’s not accurate to say Mercurial has a hidden index.

That Steve Losh post is from 2010 and it was mainly highlighting a workflow that was popular at the time for a particular use case. It also highlighted how Mercurial’s plug-in architecture can be used to to support different workflows.

Fast forward to the present and the use of MQ isn’t really a thing anymore, but is available for those who want it.

Check out https://octobus.net/blog/2020-11-26-modern-mercurial.html for modern Mercurial practices.


I find Mercurial very difficult to use. I find Git much easier.


It's just because you've been using Git for too long. Mercurial is much easier to use if you're not exposed to Git.


I used Mercurial before I used Git.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: