5 ms·
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 h
by bonzini 5y ago
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.
- masklinn 5y ago> You do that with a sequence of "git add -p" and "git commit" commands. You can do that with git commit -p.
- bonzini 5y agoTrue but there's usually a "git diff --staged" in the middle to check what I am committing.
- cryptonector 5y agoExactly!
- masklinn 5y agoYou can do that with “git show HEAD” (and “git commit --amend -p”).
- cryptonector 5y ago`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`.
- masklinn 5y ago> `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.
- martinvonz 5y ago> 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-comparison.md#the-index https://github.com/martinvonz/jj/blob/main/docs/git-comparis... for more examples.
- detaro 5y agoso 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?
- martinvonz 5y agoThat 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).
- erik_seaberg 5y agoI 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.
- cryptonector 5y agoI do that later. I do `git rebase -i` and add `exec` lines to build each commit that must build.
- cryptonector 5y ago`git add -e` is infinitely better.
- andrewshadura 5y agoTry git-crecord.