Skip to content

Commit

Permalink
document the jj equivalent of git reset --soft
Browse files Browse the repository at this point in the history
i did the following things:

1. make some changes to the working copy
2. run `jj commit`
3. before i added a description, i decided i didn't want to commit yet. in git, the way to do this is to delete the contents of the editor; git sees that it is blank and aborts the commit. in jj, this doesn't work, because descriptions are allowed to be empty.

now i have the following jj state:
```
; jj log --stat
@  pokrsyvs [email protected] 2024-02-06 21:48:17.000 -05:00 ddd6217f
│  (empty) (no description set)
│  0 files changed, 0 insertions(+), 0 deletions(-)
◉  lqqmzmku [email protected] 2024-02-06 21:48:02.000 -05:00 HEAD@git b03bf3de
│  (no description set)
│  config/jj.toml | 2 +-
│  1 file changed, 1 insertion(+), 1 deletion(-)
◉  xqkmwvwp [email protected] 2024-02-06 21:47:08.000 -05:00 master b673f97b
```
i want to undo the most recent commit, `lqqmzmku`. i'm used to doing this with `git reset --soft HEAD~`, which makes the parent `xqkmwvwp` and leaves the change to `config/jj.toml` on disk while removing it from the git history; basically `lqqmzmku` would go back to being the working copy.

i found that `jj move` does what i want, but it took a lot of trawling the options, it wasn't obvious, and i couldn't find `git reset` mentioned in the docs.
  • Loading branch information
jyn514 committed Feb 7, 2024
1 parent d66fcf2 commit 9a005d7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/git-comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,11 @@ parent.
<td><code>git reset --hard</code> (same as abandoning a change since Git
has no concept of a "change")</td>
</tr>
<tr>
<td>Abandon the current change, but keep its diff in the working copy</td>
<td><code>jj move --from @- --to @</code></td>
<td><code>git reset --soft HEAD~</code></td>
</tr>
<tr>
<td>Discard working copy changes in some files</td>
<td><code>jj restore &lt;paths&gt;...</code></td>
Expand Down

0 comments on commit 9a005d7

Please sign in to comment.