Replies: 3 comments 4 replies
-
See this FAQ: I accidentally changed files in the wrong commit, how do I move the recent changes into another commit? I do think this answer could be improved. It uses |
Beta Was this translation helpful? Give feedback.
-
Okay, I'm sure this breaks in a lot of ways, but it seems to work specifically for the situation where I've modified a change that I previously pushed as a bookmark: # fish
function jj_soft_reset
set TARGET_PARENT_REVISION $argv[1]
if [ (count $argv) -gt 1 ]
set CHANGESET_TO_SOFT_RESET $argv[2]
else
set CHANGESET_TO_SOFT_RESET "@"
end
echo "CHANGESET_TO_SOFT_RESET: $CHANGESET_TO_SOFT_RESET"
# TODO: is there a way to do this without checking out the changeset? (`jj duplicate` doesn't seem to have a way to specify the revision/changeset?)
jj edit --ignore-immutable $CHANGESET_TO_SOFT_RESET
set JJ_DUPLICATE_OUTPUT (jj duplicate 2>&1)
echo $JJ_DUPLICATE_OUTPUT
set FROM_COMMIT_ID (echo $JJ_DUPLICATE_OUTPUT | grep -o "^Duplicated [0-9a-f]\+ as [k-z]\+ " | awk "{print \$2}")
echo "FROM_COMMIT_ID: $FROM_COMMIT_ID"
set DUPLICATED_CHANGESET_ID (echo $JJ_DUPLICATE_OUTPUT | grep -o "^Duplicated [0-9a-f]\+ as [k-z]\+ " | awk "{print \$4}")
echo "DUPLICATED_CHANGESET_ID: $DUPLICATED_CHANGESET_ID"
jj edit $DUPLICATED_CHANGESET_ID
jj describe --message "(Changes from a soft reset.)"
# TODO: this doesn't work for revs that are more than 1 ancestor ago. Do the semantics `jj restore` work for this?
# TODO: produces false positives for conflicts depending on the contents of `$TARGET_PARENT_REVISION`. Can we automatically resolve conflicts to "ours"?
jj rebase --destination $TARGET_PARENT_REVISION
jj abandon $FROM_COMMIT_ID
end This is… much more complicated than I would like. 😳 |
Beta Was this translation helpful? Give feedback.
-
Did you see the discussion on #6000 jj squash --restore-descendants ? |
Beta Was this translation helpful? Give feedback.
-
I occasionally find that I forgot to run
jj new
and edited a mutable commit instead. 1https://github.com/jj-vcs/jj/blob/main/docs/git-command-table.md documents that
git reset --soft HEAD~
corresponds tojj squash --from @-
, which is unfortunately insufficient for this.What I'd like to do is:
@
.This is trivial in
git
:I've tried to look for existing issues/discussions/documentation on this, but I find myself using very complicated workarounds.
jj duplicate --destination
seems to be close but doesn't seem to produce the right results for me.Is there a simple equivalent in
jj
that works with destinations other than@-
?Footnotes
Lazy "new" could help with this, but of course doesn't exist yet. ↩
Beta Was this translation helpful? Give feedback.
All reactions