Remote Operations
jj works with git remotes but handles them differently.
Fetching Changes
jj
jj git fetchjj log| git | jj |
|---|---|
| git fetch origin | jj git fetch |
| git log origin/main | jj log |
Pulling and Rebasing
jj doesn't have jj git pull. Instead, you fetch then rebase:
jj
jj git fetchjj rebase -d main@origin| git | jj |
|---|---|
| git pull origin main | jj git fetch |
| git fetch origin | jj 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| git | jj |
|---|---|
| git push origin main | jj git push |
Setting Up Remotes
jj
jj git remote add origin https://github.com/user/repo.gitjj git remote list| git | jj |
|---|---|
| git remote add origin https://github.com/user/repo.git | jj git remote add origin https://github.com/user/repo.git |
| git remote -v | jj git remote list |
Cloning Repositories
jj
jj git clone https://github.com/user/repo.gitcd repo| git | jj |
|---|---|
| git clone https://github.com/user/repo.git | jj git clone https://github.com/user/repo.git |
| cd repo | cd 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 fetchjj rebase -d main@origin| git | jj |
|---|---|
| git pull --rebase | jj git fetch |
Multiple Remotes
jj
jj git remote add upstream https://github.com/original/repo.gitjj git fetch --remote upstream| git | jj |
|---|---|
| git remote add upstream https://github.com/original/repo.git | jj git remote add upstream https://github.com/original/repo.git |
| git fetch upstream | jj 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 fetchdownloads remote changesjj git pushuploads local changesjj rebase -d branch@originpulls changes- Use
@originsuffix 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
- 1Squash multiple commits
- 2Split a commit into two
- 3Edit commit contents inline
- 4Rebase commits onto another branch