LinuxCommandLibrary

jj-git-push

Push jj commits to Git remote

TLDR

Push a bookmark to the given remote (defaults to git.push setting)

$ jj git push [[-b|--bookmark]] [bookmark] --remote [remote]
copy

Push a new bookmark
$ jj git push [[-b|--bookmark]] [bookmark] [[-N|--allow-new]]
copy

Push all tracked bookmarks
$ jj git push --tracked
copy

Push all bookmarks (including new bookmarks)
$ jj git push --all
copy

Push all bookmarks pointing to given revisions
$ jj git push [[-r|--revisions]] [revset]
copy

Push changes/commits by creating new bookmarks (Name format is as per templates.git_push_bookmark setting, defaults to "push-" ++ change_id.short())
$ jj git push [[-c|--change]] [revset]
copy

Push a revision with the given name
$ jj git push --named [name]=[revision]
copy

SYNOPSIS

jj git push [OPTIONS] [REMOTE]

PARAMETERS

REMOTE
    The name of the remote Git repository to push to. If omitted, Jujutsu typically defaults to 'origin'.

--branch <BRANCH>
    Push only the specified branch(es). This option can be used multiple times to push several branches.

--all
    Push all Git-tracked branches from the local Jujutsu repository to the remote.

--force, -f
    Force push the changes. This can overwrite remote history and should be used with extreme caution.

--dry-run
    Perform a trial run without actually pushing any changes, showing what would be done.

--purge
    Remove remote branches that no longer exist locally in the Jujutsu repository. Use with care as it deletes remote branches.

--tool-args <ARGS>
    Pass additional arguments directly to the underlying Git push command executed by Jujutsu.

--json
    Output the command's status and results in JSON format, suitable for machine parsing.

DESCRIPTION

jj-git-push is a subcommand within the Jujutsu (jj) version control system, designed to synchronize local Jujutsu changes with a remote Git repository. Unlike the standard git push which primarily operates on Git branches, jj git push focuses on pushing Jujutsu's internal concept of Git-tracked branches and their corresponding commits. This command is essential for users who manage their projects with Jujutsu but need to collaborate with Git users or publish their work to Git-based platforms. It ensures that the state of Git branches on the remote reflects the desired state from the Jujutsu repository, effectively bridging Jujutsu's flexible history management with Git's widely adopted ecosystem.

CAVEATS

Using --force (-f) can lead to data loss or conflicts if others have based work on the overwritten history on the remote. Always communicate with your team before force pushing.

The --purge option can delete remote branches that might still be relevant to other collaborators. Exercise caution and ensure you understand its implications.

jj-git-push operates on Jujutsu's internal representation of Git-tracked branches. While designed for interoperability, it might not always behave identically to a direct git push for complex scenarios or non-standard branch configurations.

BRANCH TRACKING AND MAPPING

When using jj git push, Jujutsu maps its internal concept of 'tracked branches' (which are essentially local Jujutsu branches designated to correspond to remote Git branches) to the actual branches on the Git remote. It primarily pushes changes related to these explicitly tracked branches, rather than arbitrary commits or anonymous branch heads.

INTEGRATION WITH GIT REMOTES

For jj git push to function, the Jujutsu repository must be configured to track a Git remote. This setup allows Jujutsu to understand which local branches correspond to which remote branches, facilitating the push operation. Jujutsu maintains its own internal state of remote-tracking information, which it uses to guide the push.

HISTORY

The Jujutsu (jj) version control system is a relatively new and innovative alternative to Git, aiming to provide a more intuitive and powerful interface for managing code history. jj git push was introduced as a core component of Jujutsu's interoperability layer, allowing Jujutsu users to seamlessly interact with existing Git repositories and collaborate with Git users. Its development reflects the goal of making Jujutsu a viable daily driver for developers, without requiring them to abandon their existing Git infrastructure or workflows.

SEE ALSO

jj(1), jj-git(1), jj-git-fetch(1), git-push(1)

Copied to clipboard