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 uses Git under the hood to version-control every change to your notebooks. With nb remote, nb sync, and nb git you can push notebooks to any Git hosting service, keep multiple machines in sync automatically, and run raw git commands when you need full control. Each notebook has its own independent git history, so you can sync some notebooks to a remote while keeping others local.
nb sync
nb sync manually syncs the current notebook with its configured remote repository.
Usage
Options
Sync all unarchived notebooks that have a remote configured.
How Automatic Sync Works
Any notebook with a remote URL configured will sync automatically every time a command is run in that notebook (e.g.nb add, nb edit, nb delete). To disable this behavior, set nb set auto_sync 0.
Manual Sync
Conflict Resolution
Whennb sync encounters a text file conflict that cannot be cleanly merged, both versions are saved in the file separated by git conflict markers:
nb edit to remove the conflict markers and delete the unwanted version. To keep both items, simply delete the three marker lines:
nb sync encounters a binary file conflict (e.g. an encrypted note), both versions are saved as individual files. The remote version gets --conflicted-copy appended to its filename. Resolve by comparing the two files, merging manually, then deleting the --conflicted-copy.
nb remote
nb remote configures the Git remote URL and branch for the current notebook.
Usage
Subcommands
| Subcommand | Description |
|---|---|
| (default) | Print the current remote URL and branch |
set | Set the remote URL and optionally a branch name |
remove | Remove the remote URL from the notebook. Alias: unset |
branches | List all branches on the current or a given remote |
rename | Rename the current orphan branch or a named branch |
delete | Delete an orphan branch from the remote |
reset | Reset a remote branch to a blank initial state |
Setting a Remote
Removing a Remote
Listing Remote Branches
Syncing Multiple Notebooks to One Remote
You can sync multiple notebooks to a single remote repository using orphan branches — branches with independent git histories that share no common ancestry with the main branch. When you runnb remote set, nb will offer to create a new orphan branch. The branch name is derived from the notebook name, or you can specify it explicitly:
nb git
nb git runs git commands directly within the current notebook directory, bypassing nb logic. Use it for advanced operations that nb doesn’t expose, or when you need to resolve a conflict manually.
Usage
Subcommands
Create a new git commit in the current notebook and sync with the remote if
nb set auto_sync is enabled. Optionally provide a custom commit message.Exit with status
0 (success / true) if there are uncommitted changes in the current notebook. Exit with status 1 (error / false) if the notebook is clean.Pass-Through Git Commands
Any git command and its arguments can be passed directly:Manual Checkpoint
Create a commit manually, with an optional custom message:nb status
nb status prints the archival, git, and remote status for the current notebook or a named notebook.
Usage
Examples
nb init
nb init initializes the initial home notebook and generates the ~/.nbrc configuration file. Pass a remote URL and optional branch to clone an existing notebook instead of starting fresh.
Usage
Options
URL of an existing remote repository to clone as the initial
home notebook.Branch name to check out from the remote. Used to access orphan branches storing specific notebooks.
Display the local email and name configuration prompt.
Set the local git commit author email address.
Set the local git commit author name.
Examples
Setting Up Sync with GitHub or GitLab
Create a private repository
Create a new private repository on GitHub or GitLab. Do not initialize it with a README.
Configure git credentials
For HTTPS, cache credentials so git doesn’t prompt for a password on every sync:For SSH, generate a key and add it to the ssh-agent:
Sync manually to verify