Skip to main content
jj-git

Remote Operations

Step 6 of 12

Remote Operations

jj works with git remotes but handles them differently.

Fetching Changes

jj
jj git fetch
jj log
Command comparison: git commands on the left, jj commands on the right
gitjj
git fetch originjj git fetch
git log origin/mainjj log

Pulling and Rebasing

jj doesn't have jj git pull. Instead, you fetch then rebase:

jj
jj git fetch
jj rebase -d main@origin
Command comparison: git commands on the left, jj commands on the right
gitjj
git pull origin mainjj git fetch
git fetch originjj rebase -d main@origin
git rebase origin/main
NOTE:

The @origin suffix denotes the remote-tracking branch. main@origin is the remote's version of main.

Pushing Changes

jj
jj git push
Command comparison: git commands on the left, jj commands on the right
gitjj
git push origin mainjj git push

Setting Up Remotes

jj
jj git remote add origin https://github.com/user/repo.git
jj git remote list
Command comparison: git commands on the left, jj commands on the right
gitjj
git remote add origin https://github.com/user/repo.gitjj git remote add origin https://github.com/user/repo.git
git remote -vjj git remote list

Cloning Repositories

jj
jj git clone https://github.com/user/repo.git
cd repo
Command comparison: git commands on the left, jj commands on the right
gitjj
git clone https://github.com/user/repo.gitjj git clone https://github.com/user/repo.git
cd repocd repo

Both create a git repository. To use jj:

cd repo
jj git init --colocate

Typical Remote Workflow

# 1. Fetch latest changes
jj git fetch

# 2. Rebase your work on top of remote
jj rebase -d main@origin

# 3. Make your changes
jj describe -m "New feature"
jj new

# 4. Push to remote
jj git push

Colocated Workflow

Since jj and git share the same .git directory:

# Use jj for daily work
jj status
jj log
jj describe -m "Work"
jj new

# Use git for remotes if needed
git push
git fetch

But it's better to use jj's git commands:

jj git fetch
jj git push

Handling Divergence

If your local and remote have diverged:

jj
jj git fetch
jj rebase -d main@origin
Command comparison: git commands on the left, jj commands on the right
gitjj
git pull --rebasejj git fetch

Multiple Remotes

jj
jj git remote add upstream https://github.com/original/repo.git
jj git fetch --remote upstream
Command comparison: git commands on the left, jj commands on the right
gitjj
git remote add upstream https://github.com/original/repo.gitjj git remote add upstream https://github.com/original/repo.git
git fetch upstreamjj git fetch --remote upstream

Git Compatibility

Since jj uses git's storage:

  • Use git GUI tools (GitHub Desktop, SourceTree, etc.)
  • CI/CD systems work unchanged
  • Host services (GitHub, GitLab) just see git

You get jj's UX with git's compatibility.

Try It Yourself

In the sandbox, you can explore the basic commands (remote operations require a connected repository):

$
$

Key Takeaways

  • jj git fetch downloads remote changes
  • jj git push uploads local changes
  • jj rebase -d branch@origin pulls changes
  • Use @origin suffix for remote-tracking branches
  • jj and git can work on the same repo

Next Steps

Now let's learn about jj's powerful revset syntax for querying commits.

Practice Exercises

0/4 completed

  1. 1Squash multiple commits
  2. 2Split a commit into two
  3. 3Edit commit contents inline
  4. 4Rebase commits onto another branch