jj-git
Synchronize Jujutsu with Git remote
TLDR
Create a new Git backed repository
Create a new repository backed by a clone of a Git repository
Fetch from a Git remote
Push all tracked bookmarks to Git remote
Push given bookmark to Git remote
SYNOPSIS
jj git subcommand [options] [arguments]
PARAMETERS
fetch
Synchronizes the local Jujutsu repository with changes from configured Git remotes. This pulls new commits and updates Git remote-tracking branches within Jujutsu's view, allowing you to see and integrate the latest upstream changes.
push
Pushes local Jujutsu commits to a specified Git remote. This command typically exports the current branch or designated changesets, making them available in the Git repository. Common options include --branch (to specify branches to push) and --force (to force-push, potentially overwriting remote history).
export
Explicitly exports Jujutsu commits to local Git refs (e.g., branches or tags) without interacting with a remote. Useful for inspecting the Git view of Jujutsu's state locally, creating specific local Git branches from Jujutsu, or for more advanced integration scenarios.
import
Imports Git refs (like branches or tags) from the local Git repository into Jujutsu's internal state. This makes Git-managed commits accessible and manageable within Jujutsu, often used when migrating an existing Git repository to Jujutsu.
remote
Manages Git remotes configured for the Jujutsu repository. This subcommand itself has further subcommands like add (to add a new remote), remove (to delete a remote), and list (to display configured remotes), mirroring Git's remote management functionalities.
[common options]
Many jj git subcommands, especially push and fetch, accept common Git-like options such as --branch <branches> (to specify branches), --force (to force operations), and --dry-run (to show what would happen without making changes).
DESCRIPTION
The jj git command group within the Jujutsu (jj) version control system provides essential functionalities for interacting with traditional Git repositories. It serves as a crucial bridge, enabling users to leverage Jujutsu's powerful features, such as stacked changes and mutable history, while seamlessly collaborating with teams and systems that primarily rely on Git. This suite of subcommands facilitates fetching changes from Git remotes, pushing local Jujutsu commits to Git branches, and managing the synchronization between Jujutsu's internal state and Git's commit graph. By integrating import and export capabilities, jj git ensures compatibility with existing Git workflows and infrastructure, simplifying adoption and improving development fluidity for mixed environments.
CAVEATS
Understanding the mapping between Jujutsu's stacked changes and Git's linear history is crucial, as is managing potential conflicts during synchronization. While jj git aims for seamless interoperability, advanced Git operations or non-standard repository structures might require careful handling. Users should be aware that Git's state is a projection of Jujutsu's, not the other way around.
SYNCHRONIZATION MODEL
jj git operates on a principle of maintaining a clear separation between Jujutsu's internal commit graph (with its mutable history and stacked changes) and the traditional Git repository's state. When you fetch, Jujutsu updates its view of Git's remote-tracking branches. When you push, Jujutsu carefully exports its selected commits to Git branches, translating its internal representation to a Git-compatible one. This design allows Jujutsu to offer its unique features while still providing a well-defined pathway for Git interaction.
CONFIGURATION OF REMOTES
Git remotes and their URLs are configured within Jujutsu using the jj git remote subcommand, or by directly editing the Jujutsu configuration file. This mirrors how Git remotes are managed, ensuring familiar setup and interaction with upstream and downstream repositories.
JUJUTSU BRANCHES VS. GIT BRANCHES
It's important to distinguish between Jujutsu's concept of branches (managed by jj branch) and Git's branches. While both are used to track lines of development, jj git push and jj git export are the primary commands used to explicitly map and synchronize Jujutsu-managed branches to corresponding Git branches for collaboration.
HISTORY
The jj git subcommand group is a fundamental component of the Jujutsu (jj) SCM, which began active development around 2020-2021 as a modern alternative to Git with a focus on usability and powerful commit graph manipulation. From its early stages, interoperability with Git was a core design principle, recognizing Git's widespread adoption. The git subcommand was thus implemented to ensure that Jujutsu users could easily work with existing Git repositories and collaborate with Git users, making the transition to Jujutsu more practical for teams and individuals.