Skip to content

Commit

Permalink
jj git push docs: document safety checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Apr 8, 2024
1 parent 93cebcd commit f9bd67a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cli/src/commands/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,26 @@ pub struct GitCloneArgs {
/// `remote_branches(remote=<remote>)..@`. Use `--branch` to push specific
/// branches. Use `--all` to push all branches. Use `--change` to generate
/// branch names based on the change IDs of specific commits.
///
/// Before actually performing the push on a branch, several safety checks are
/// made.
///
/// 1. `jj` will contact the remote and check that the actual state of the
/// remote branch matches `jj`'s record of its last known position. If they
/// do not match, `jj` will refuse to push the branch. In this case, you need
/// to `jj git fetch --remote <remote name>`. This may create some branch
/// conflicts, which you'll need to resolve before trying `jj git push`
/// again.
///
/// If you are familiar with Git, this makes `jj git push` similar to `git
/// push --force-with-lease`.
/// 2. The local branch must not be [conflicted]. If it is, you would need to
/// use `jj branch set`, for example, to resolve the conflict.
/// 3. If the remote branch already exists on the remote, it must be [tracked].
///
/// [conflicted]: https://martinvonz.github.io/jj/latest/branches/#conflicts
/// [tracked]: https://martinvonz.github.io/jj/latest/branches/#remotes-and-tracked-branches

#[derive(clap::Args, Clone, Debug)]
#[command(group(ArgGroup::new("specific").args(&["branch", "change", "revisions"]).multiple(true)))]
#[command(group(ArgGroup::new("what").args(&["all", "deleted", "tracked"]).conflicts_with("specific")))]
Expand Down

0 comments on commit f9bd67a

Please sign in to comment.