2023-08-04 16:02:35 +00:00
|
|
|
# Frequently asked questions
|
|
|
|
|
|
|
|
### Why does my branch not move to the new commit after `jj new/commit`?
|
|
|
|
|
|
|
|
If you're familiar with Git, you might expect the current branch to move forward
|
2023-08-09 00:13:22 +00:00
|
|
|
when you commit. However, Jujutsu does not have a concept of a "current branch".
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
To move branches, use `jj branch set`.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
|
|
|
### I made a commit and `jj git push --all` says "Nothing changed" instead of pushing it. What do I do?
|
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
`jj git push --all` pushes all _branches_, not all revisions. You have two
|
|
|
|
options:
|
2023-08-04 16:02:35 +00:00
|
|
|
|
|
|
|
* Using `jj git push --change` will automatically create a branch and push it.
|
2023-08-09 00:13:22 +00:00
|
|
|
* Using `jj branch` commands to create or move a branch to either the commit
|
|
|
|
you want to push or a descendant on it. Unlike Git, Jujutsu doesn't do this
|
|
|
|
automatically (see previous question).
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
### Where is my commit, why is it not visible in `jj log`?
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
Is your commit visible with `jj log -r 'all()'`?
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
If yes, you should be aware that `jj log` only shows the revisions matching
|
|
|
|
`revsets.log` by default. You can change it as described in [config] to show
|
|
|
|
more revisions.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
If not, the revision may have been abandoned (e.g. because you
|
|
|
|
used `jj abandon`, or because it's an obsolete version that's been rewritten
|
|
|
|
with `jj rebase`, `jj describe`, etc). In that case, `jj log -r commit_id`
|
|
|
|
should show the revision as "hidden". `jj new commit_id` should make the
|
2023-08-04 16:02:35 +00:00
|
|
|
revision visible again.
|
|
|
|
|
|
|
|
See [revsets] and [templates] for further guidance.
|
|
|
|
|
|
|
|
### Can I prevent Jujutsu from recording my unfinished work? I'm not ready to commit it.
|
|
|
|
|
|
|
|
Jujutsu automatically records new files in the current working-copy commit and
|
|
|
|
doesn't provide a way to prevent that.
|
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
However, you can easily record intermediate drafts of your work. If you think
|
|
|
|
you might want to go back to the current state of the working-copy commit,
|
|
|
|
simply use `jj new`. There's no need for the commit to be "finished" or even
|
|
|
|
have a description.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
Then future edits will go into a new working-copy commit on top of the now
|
|
|
|
former working-copy commit. Whenever you are happy with another set of edits,
|
|
|
|
use `jj squash` to amend the previous commit.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
|
|
|
For more options see the next question.
|
|
|
|
|
2023-10-21 23:26:45 +00:00
|
|
|
### Can I interactively create a new commit from only some of the changes in the working copy, like `git add -p && git commit` or `hg commit -i`?
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-10-21 23:26:45 +00:00
|
|
|
Since the changes are already in the working-copy commit, the equivalent to
|
|
|
|
`git add -p && git commit`/`git commit -p`/`hg commit -i` is to split the
|
|
|
|
working-copy commit with `jj split -i` (or the practically identical
|
|
|
|
`jj commit -i`).
|
|
|
|
|
|
|
|
For the equivalent of `git commit --amend -p`/`hg amend -i`, use `jj squash -i`.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
### Is there something like `git rebase --interactive` or `hg histedit`?
|
2023-08-04 16:02:35 +00:00
|
|
|
|
|
|
|
Not yet, you can check [this issue] for updates.
|
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
To reorder commits, it is for now recommended to rebase commits individually,
|
2023-08-04 16:02:35 +00:00
|
|
|
which may require multiple invocations of `jj rebase -r` or `jj rebase -s`.
|
|
|
|
|
|
|
|
To squash or split commits, use `jj squash` and `jj split`.
|
|
|
|
|
|
|
|
### How can I keep my scratch files in the repository?
|
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
You can keep your notes and other scratch files in the repository, if you add
|
|
|
|
a wildcard pattern to either the repo's `gitignore` or your global `gitignore`.
|
2023-08-04 16:02:35 +00:00
|
|
|
Something like `*.scratch` or `*.scratchpad` should do, after that rename the
|
2023-08-09 00:13:22 +00:00
|
|
|
files you want to keep around to match the pattern.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
If `$EDITOR` integration is important, something like `scratchpad.*` may be more
|
|
|
|
helpful, as you can keep the filename extension intact (it
|
|
|
|
matches `scratchpad.md`, `scratchpad.rs` and more).
|
2023-08-04 16:02:35 +00:00
|
|
|
|
|
|
|
You can find more details on `gitignore` files [here][gitignore].
|
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
### How can I keep local changes around, but not use them for Pull Requests?
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
In general, you should separate out the changes to their own commit (using
|
|
|
|
e.g. `jj split`). After that, one possible workflow is to rebase your pending
|
|
|
|
PRs on top of the commit with the local changes. Then, just before pushing to a
|
|
|
|
remote, use `jj rebase -s child_of_commit_with_local_changes -d main` to move
|
|
|
|
the PRs back on top of `main`.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
2023-08-09 00:13:22 +00:00
|
|
|
If you have several PRs, you can
|
|
|
|
try `jj rebase -s all:commit_with_local_changes+ -d main`
|
|
|
|
(note the `+`) to move them all at once.
|
2023-08-04 16:02:35 +00:00
|
|
|
|
|
|
|
An alternative workflow would be to rebase the commit with local changes on
|
|
|
|
top of the PR you're working on and then do `jj new commit_with_local_changes`.
|
2023-08-09 00:13:22 +00:00
|
|
|
You'll then need to use `jj new --before` to create new commits
|
|
|
|
and `jj move --to`
|
2023-08-04 16:02:35 +00:00
|
|
|
to move new changes into the correct commits.
|
|
|
|
|
2023-09-08 15:29:21 +00:00
|
|
|
### I accidentally amended the working copy. How do I move the new changes into its own commit?
|
|
|
|
|
|
|
|
Use `jj obslog -p` to see how your working-copy commit has evolved. Find the
|
|
|
|
commit you want to restore the contents to. Let's say the current commit (with
|
|
|
|
the changes intended for a new commit) are in commit X and the state you wanted
|
|
|
|
is in commit Y. Note the commit id (normally in blue at the end of the line in
|
|
|
|
the log output) of each of them. Now use `jj new` to create a new working-copy
|
|
|
|
commit, then run `jj restore --from Y --to @-` to restore the parent commit
|
|
|
|
to the old state, and `jj restore --from X` to restore the new working-copy
|
|
|
|
commit to the new state.
|
|
|
|
|
2023-10-31 05:21:06 +00:00
|
|
|
### How do I deal with divergent changes ('??' after the [change ID][glossary_change_id])?
|
|
|
|
|
|
|
|
A [divergent change][glossary_divergent_change] represents a change that has two
|
|
|
|
or more visible commits associated with it. To refer to such commits, you must
|
|
|
|
use their [commit ID][glossary_commit_id]. Most commonly, the way to resolve
|
|
|
|
this is to abandon the unneeded commits (using `jj abandon <commit ID>`). If you
|
|
|
|
would like to keep both commits with this change ID, you can `jj duplicate` one
|
|
|
|
of them before abandoning it.
|
|
|
|
|
|
|
|
Usually, the different commits associated with the divergent change ID should all
|
|
|
|
appear in the log, but due to #2476, they may not. If that happens, you can
|
|
|
|
either use `jj log -r 'all()' | grep <change id>` or disable the
|
|
|
|
`revsets.short-prefixes` config option.
|
|
|
|
|
|
|
|
### How do I deal with conflicted branches ('??' after branch name)?
|
|
|
|
|
|
|
|
A [conflicted branch][branches_conflicts] is a branch that refers to multiple
|
|
|
|
different commits because jj couldn't fully resolve its desired position.
|
|
|
|
Resolving conflicted branches is usually done by setting the branch to the
|
|
|
|
correct commit using `jj branch set <commit ID>`.
|
|
|
|
|
|
|
|
Usually, the different commits associated with the conflicted branch should all
|
|
|
|
appear in the log, but if they don't you can use `jj branch list`to show all the
|
|
|
|
commits associated with it.
|
|
|
|
|
|
|
|
[branches_conflicts]: branches.md#conflicts
|
|
|
|
|
2023-08-13 02:16:41 +00:00
|
|
|
[config]: config.md
|
2023-08-09 00:13:22 +00:00
|
|
|
|
2023-08-04 16:02:35 +00:00
|
|
|
[gitignore]: https://git-scm.com/docs/gitignore
|
2023-08-09 00:13:22 +00:00
|
|
|
|
2023-10-31 05:21:06 +00:00
|
|
|
[glossary_change_id]: glossary.md#change-id
|
|
|
|
|
|
|
|
[glossary_commit_id]: glossary.md#commit-id
|
|
|
|
|
|
|
|
[glossary_divergent_change]: glossary.md#divergent-change
|
|
|
|
|
2023-08-13 02:16:41 +00:00
|
|
|
[revsets]: revsets.md
|
2023-08-09 00:13:22 +00:00
|
|
|
|
2023-08-13 02:16:41 +00:00
|
|
|
[templates]: templates.md
|
2023-08-09 00:13:22 +00:00
|
|
|
|
2023-08-04 16:02:35 +00:00
|
|
|
[this issue]: https://github.com/martinvonz/jj/issues/1531
|