1 Git Integration
riomoo edited this page 2026-04-08 18:34:42 -04:00

Git Integration

Every nt command that modifies a note automatically stages and commits the change. You never need to run git yourself for day-to-day use. The full git history is available via nt log, and raw git access is available via nt git.


Auto-Commit Messages

Action Commit message
nt new <n> add: <n>
nt edit <n> update: <n>
nt delete <n> delete: <n>
nt add <n> task ... add task to <n>
nt add <n> link ... add link to <n>
nt add <n> table ... add table to <n>
nt add <n> line ... add line to <n>
nt check <n> ... check item in <n>
nt uncheck <n> ... uncheck item in <n>
nt toggle <n> toggle checkbox in <n>

Commits are only created when the file content actually changed — saving without edits produces no commit.


Viewing History

nt log

Equivalent to git log --oneline --graph --decorate --color run inside the notes repo.


Setting Up a Remote (Backup / Sync)

Push your notes to any git host for backup or multi-device sync:

# GitHub
nt git remote add origin git@github.com:you/notes-private.git
nt git push -u origin main

# Forgejo / Gitea (self-hosted)
nt git remote add origin git@git.example.com:you/notes.git
nt git push -u origin main

After the initial push, nt git push syncs new commits.


Pulling on Another Machine

# Clone the repo directly into ~/.config/nt
git clone git@github.com:you/notes-private.git ~/.config/nt

nt will detect the existing .git directory and skip re-initialisation.


nt git Passthrough

Any git command can be run against the notes repository:

nt git status
nt git diff HEAD~1
nt git log --all --stat
nt git stash
nt git pull --rebase
nt git remote -v

Repository Location

The notes repo lives at ~/.config/nt. You can also interact with it directly:

cd ~/.config/nt
git log
git diff