Move changes to a remote revision into a new revision #2400
-
Hello, I sometimes get in trouble by editing a remote commit and I would like to move these changes into a new commit. Example: jj edit main # Should have done `jj co main` to create a new revision
# edit some files and save
jj log
# Now there is a * next to the branch main
# I can see the diff with my local changes
jj diff --from main@origin --to main How can I restore the revision to main and put the changes in a new revision? Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
martinvonz
Oct 19, 2023
Replies: 1 comment 4 replies
-
Since jj 0.10.0, it will try to prevent you from rewriting remote commits. You can configure the set of commits you consider immutable. There's also an FAQ entry explaining how to recover if you've accidentally modified a non-remote commit. But for your case, where you modified a remote commit, one way of fixing it is this:
HTH |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
jbcdnr
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since jj 0.10.0, it will try to prevent you from rewriting remote commits. You can configure the set of commits you consider immutable.
There's also an FAQ entry explaining how to recover if you've accidentally modified a non-remote commit.
But for your case, where you modified a remote commit, one way of fixing it is this:
jj co main@origin
to create a new change on top of the remote branch. You will now have two commits with the same change id (aka divergence)jj restore --from main
to copy the state from that commit into your new changejj abandon main
since you don't want that version. This will resolve the divergence and move the branch backwardsjj branch set main -…