Every time you add, edit, or delete a note,Documentation Index
Fetch the complete documentation index at: https://mintlify.com/xwmx/nb/llms.txt
Use this file to discover all available pages before exploring further.
nb silently records that change as a Git commit in the notebook’s local repository. This means every notebook is a full Git repo from the moment it is created — no setup required. When you attach a remote to a notebook, those commits can be pushed and pulled automatically, giving you seamless, version-controlled sync across any number of machines without ever running a Git command yourself.
How nb Uses Git
Each notebook directory is an independent Git repository.nb calls git commit in the background after every operation that modifies the notebook’s contents — adds, edits, deletes, and moves are all captured automatically. Because each notebook has its own Git history, you can sync some notebooks to remote repositories while keeping others entirely local.
Setting and Viewing a Remote
Usenb remote set to attach a remote URL to the current notebook:
Cloning an Existing Remote Notebook
To pull an existing remote notebook down to a new machine, pass the URL tonb notebooks add:
Syncing
Once a remote is set,nb syncs that notebook automatically every time a command runs within it. You can also sync on demand:
Auto-Sync Configuration
Auto-sync is enabled by default. Theauto_sync setting controls whether nb pushes and pulls on every git checkpoint call:
$NB_AUTO_SYNC and $NB_AUTO_SYNC_SECONDS environment variables provide additional control:
| Variable | Default | Description |
|---|---|---|
$NB_AUTO_SYNC | 1 | Set to 0 to disable automatic syncing entirely. |
$NB_AUTO_SYNC_SECONDS | 60 | Minimum seconds between automatic sync operations. Set to 0 to sync on every commit. |
Syncing Multiple Notebooks to One Remote
Multiple notebooks can share a single remote repository by using orphan branches — branches whose history is completely independent from the repository’s primary branch. When you runnb remote set, nb gives you the option to create a new orphan branch. You can also specify a branch name directly:
Private Repositories and Git Credentials
Syncing with private repositories requires configuring Git so it does not prompt for credentials during an automated sync.- SSH (recommended)
- HTTPS with credential caching
Generate an SSH key and add it to the ssh-agent so Git can authenticate without a password prompt:Then add the public key to your GitHub / GitLab account. Clone or set remotes using the SSH URL format:
git@github.com:example/example.git.Use
nb sync within the notebook to test your credential setup. If a password prompt appears, credentials are not yet configured correctly. nb does not cache or store Git credentials itself.Sync Conflict Resolution
nb handles Git operations automatically and resolves most conflicts without any manual intervention using a union merge strategy.
Text file conflicts: When nb sync finds overlapping local and remote changes that cannot be cleanly merged, it saves both versions inside the file separated by standard Git conflict markers and prints a message identifying the affected files. Use nb edit to open the file, remove the conflict markers, and keep the content you want:
<<<<<<<, =======, and >>>>>>> lines to resolve:
nb saves both versions as separate files in the notebook, appending --conflicted-copy to the filename of the remote version. Compare them, merge manually, and delete the --conflicted-copy file to resolve.
Running Raw Git Commands
To run arbitrary Git commands directly inside a notebook’s directory, usenb git:
Checkpoints
nb git checkpoint creates a manual commit and syncs with the remote (if auto-sync is enabled):
Dirty State
nb git dirty exits with 0 (success) if there are uncommitted changes in the notebook, or 1 if the notebook is clean — useful in scripts:
Notebook Status
nb status prints a summary of the current notebook, including remote URL, branch, and any pending changes:
Alternative Sync with Dropbox or rsync
If you prefer to sync notes through a cloud storage service instead of (or in addition to) Git remotes, pointnb’s notebook directory at a Dropbox, Google Drive, Box, or Syncthing folder: