2022-01-04 05:38:34 +00:00
|
|
|
# Git compatibility
|
|
|
|
|
|
|
|
Jujutsu has two backends for storing commits. One of them uses a regular Git
|
|
|
|
repo, which means that you can collaborate with Git users without them even
|
|
|
|
knowing that you're not using the `git` CLI.
|
|
|
|
|
|
|
|
See `jj help git` for help about the `jj git` family of commands, and e.g.
|
2022-03-05 17:47:08 +00:00
|
|
|
`jj help git push` for help about a specific command (use `jj git push -h` for
|
|
|
|
briefer help).
|
2022-01-04 05:38:34 +00:00
|
|
|
|
|
|
|
|
2022-03-10 05:14:59 +00:00
|
|
|
## Supported features
|
|
|
|
|
|
|
|
The following list describes which Git features Jujutsu is compatible with. For
|
|
|
|
a comparison with Git, including how workflows are different, see the
|
|
|
|
[Git-comparison doc](git-comparison.md).
|
|
|
|
|
2022-03-12 00:40:08 +00:00
|
|
|
* **Configuration: Partial.** The only configuration from Git (e.g. in
|
|
|
|
`~/.gitconfig`) that's respected is the following. Feel free to file a bug if
|
|
|
|
you miss any particular configuration options.
|
|
|
|
* The configuration of remotes (`[remote "<name>"]`).
|
2022-10-21 17:53:10 +00:00
|
|
|
* `core.excludesFile`
|
2022-03-10 05:14:59 +00:00
|
|
|
* **Authentication: Partial.** Only `ssh-agent` or a password-less key file at
|
|
|
|
`~/.ssh/id_rsa` (and only at exactly that path).
|
|
|
|
* **Branches: Yes.** You can read more about
|
|
|
|
[how branches work in Jujutsu](branches.md)
|
|
|
|
and [how they interoperate with Git](#branches).
|
|
|
|
* **Tags: Partial.** You can check out tagged commits by name (pointed to be
|
|
|
|
either annotated or lightweight tags), but you cannot create new tags.
|
|
|
|
* **.gitignore: Partial.** No support for ignores in `.git/info/exclude`
|
|
|
|
([#65](https://github.com/martinvonz/jj/issues/65)) or via `core.excludesfile`
|
|
|
|
config ([#87](https://github.com/martinvonz/jj/issues/87)). Also, it uses a
|
|
|
|
native implementation, so please report a bug if you notice any difference
|
|
|
|
compared to `git`.
|
|
|
|
* **.gitattributes: No.** There's [#53](https://github.com/martinvonz/jj/issues/53)
|
|
|
|
about adding support for at least the `eol` attribute.
|
2022-09-26 15:59:13 +00:00
|
|
|
* **Hooks: No.** There's [#405](https://github.com/martinvonz/jj/issues/405)
|
|
|
|
specifically for providing the checks from https://pre-commit.com.
|
2022-03-10 05:14:59 +00:00
|
|
|
* **Merge commits: Yes.** Octopus merges (i.e. with more than 2 parents) are
|
|
|
|
also supported.
|
|
|
|
* **Detached HEAD: Yes.** Jujutsu supports anonymous branches, so this is a
|
|
|
|
natural state.
|
|
|
|
* **Orphan branch: Yes.** Jujutsu has a virtual root commit that appears as
|
|
|
|
parent of all commits Git would call "root commits".
|
|
|
|
* **Staging area: Kind of.** The staging area will be ignored. For example,
|
|
|
|
`jj diff` will show a diff from the Git HEAD to the working copy. There are
|
2022-09-09 17:41:54 +00:00
|
|
|
[ways of fulfilling your use cases without a staging
|
2022-03-10 05:14:59 +00:00
|
|
|
area](https://github.com/martinvonz/jj/blob/main/docs/git-comparison.md#the-index).
|
|
|
|
* **Garbage collection: Yes.** It should be safe to run `git gc` in the Git
|
|
|
|
repo, but it's not tested, so it's probably a good idea to make a backup of
|
|
|
|
the whole workspace first. There's [no garbage collection and repacking of
|
|
|
|
Jujutsu's own data structures yet](https://github.com/martinvonz/jj/issues/12),
|
|
|
|
however.
|
|
|
|
* **Bare repositories: Yes.** You can use `jj init --git-repo=<path>` to create
|
|
|
|
a repo backed by a bare Git repo.
|
|
|
|
* **Submodules: No.** They will not show up in the working copy, but they will
|
|
|
|
not be lost either.
|
|
|
|
* **Partial clones: No.** We use the [libgit2](https://libgit2.org/) library,
|
|
|
|
which doesn't have support for partial clones.
|
|
|
|
* **git-worktree: No.** However, there's native support for multiple working
|
|
|
|
copies backed by a single repo. See the `jj workspace` family of commands.
|
2022-02-06 23:10:50 +00:00
|
|
|
* **Sparse checkouts: No.** However, there's native support for sparse
|
|
|
|
checkouts. See the `jj sparse` command.
|
2022-03-10 05:14:59 +00:00
|
|
|
* **Signed commits: No.** ([#58](https://github.com/martinvonz/jj/issues/58))
|
|
|
|
* **Git LFS: No.** ([#80](https://github.com/martinvonz/jj/issues/80))
|
|
|
|
|
|
|
|
|
2022-01-04 05:38:34 +00:00
|
|
|
## Creating an empty repo
|
2022-03-10 05:14:59 +00:00
|
|
|
|
2022-01-04 05:38:34 +00:00
|
|
|
To create an empty repo using the Git backend, use `jj init --git <name>`. Since
|
|
|
|
the command creates a Jujutsu repo, it will have a `.jj/` directory. The
|
|
|
|
underlying Git repo will be inside of that directory (currently in
|
2022-02-18 06:20:14 +00:00
|
|
|
`.jj/repo/store/git/`).
|
2022-01-04 05:38:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
## Creating a repo backed by an existing Git repo
|
|
|
|
|
|
|
|
To create a Jujutsu repo backed by a Git repo you already have on disk, use
|
2022-02-02 16:10:36 +00:00
|
|
|
`jj init --git-repo=<path to Git repo> <name>`. The repo will work similar to a
|
|
|
|
[Git worktree](https://git-scm.com/docs/git-worktree), meaning that the working
|
2022-09-18 21:46:12 +00:00
|
|
|
copies files and the record of the working-copy commit will be separate, but the
|
|
|
|
commits will be accessible in both repos. Use `jj git import` to update the
|
|
|
|
Jujutsu repo with changes made in the Git repo. Use `jj git export` to update
|
|
|
|
the Git repo with changes made in the Jujutsu repo.
|
2022-01-04 05:38:34 +00:00
|
|
|
|
2022-09-18 21:46:12 +00:00
|
|
|
If you initialize the Jujutsu repo in the same working copy as the Git repo by
|
|
|
|
running `jj init --git-repo=.`, then the import and export will happen
|
2022-01-04 05:38:34 +00:00
|
|
|
automatically on every command (because not doing that makes it very confusing
|
2022-09-18 21:46:12 +00:00
|
|
|
when the working copy has changed in Git but not in Jujutsu or vice versa). This
|
|
|
|
mode is meant to make it easier to start using readonly `jj` commands in an
|
2022-01-04 05:38:34 +00:00
|
|
|
existing Git repo. You should then be able to switch to using mutating `jj`
|
|
|
|
commands and readonly Git commands. The mode is new and not tested much, and
|
|
|
|
interleaving mutating `jj` and `git` commands might not work well (feel free
|
|
|
|
to report bugs).
|
|
|
|
|
|
|
|
|
|
|
|
## Creating a repo by cloning a Git repo
|
|
|
|
|
|
|
|
To create a Jujutsu repo from a remote Git URL, use `jj git clone <URL>
|
|
|
|
[<destination>]`. For example, `jj git clone
|
|
|
|
https://github.com/octocat/Hello-World` will clone GitHub's "Hello-World" repo
|
|
|
|
into a directory by the same name.
|
|
|
|
|
|
|
|
|
|
|
|
## Branches
|
|
|
|
|
|
|
|
TODO: Describe how branches are mapped
|
|
|
|
|
|
|
|
|
|
|
|
## Format mapping details
|
|
|
|
|
|
|
|
Paths are assumed to be UTF-8. I have no current plans to support paths with
|
|
|
|
other encodings.
|
|
|
|
|
|
|
|
Commits created by `jj` have a ref starting with `refs/jj/` to prevent GC.
|
|
|
|
|
|
|
|
Commit metadata that cannot be represented in Git commits (such as the Change
|
|
|
|
ID) is stored outside of the Git repo (currently in `.jj/store/extra/`).
|
|
|
|
|
|
|
|
Paths with conflicts cannot be represented in Git. They appear as files with
|
|
|
|
a `.jjconflict` suffix in the Git repo. They contain a JSON representation with
|
|
|
|
information about the conflict. They are not meant to be human-readable.
|