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 :)
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.
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)
Sign me up!
Happy user for at least 6 years.
The sanity of Mercurial's UX cannot be overstated.
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.
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...?
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...
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).
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.
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.
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.
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.
`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.
You can do that with git commit -p.
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.
: ; $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.> detached HEAD mode
Ah, I see, not anymore...
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.
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.
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.