Git for notes: version history for a Markdown folder
Use Git for notes to get full version history: start a repository in your notes folder, commit daily, see what changed with git diff and restore old versions.

Using Git for notes means turning your Markdown notes folder into a Git repository and committing your changes regularly, so every version of every note is kept. You run git init once, commit at the end of each day (or let a script do it), and from then on you can see exactly what changed in a note, bring back a paragraph you deleted, or restore a note you removed months ago. Git works on plain text files, which is what Markdown notes are, and it needs no server unless you want an offsite copy.
Below are the setup commands, a .gitignore for notes, the handful of commands you actually need, and the limits worth knowing before you rely on it.
Why use Git for notes?
Because it gives you a complete, local history of your writing that does not depend on any app. Most note apps keep some version history, but it lives inside the app, often for a limited time.
What Git adds to a notes folder:
- Every version, forever. Each commit is a snapshot you can return to.
- Readable changes.
git diffshows the exact words you added or removed. - Undelete. A note deleted a year ago is still in the history.
- A record of when.
git logtells you when a note changed, which helps when you are trying to remember when you decided something. - Optional remote copy. Push to a private repository on a server you trust for an offsite copy.
Git is not a sync tool in the way a cloud drive is. It moves changes only when you commit, push and pull. If you mainly want the same notes on several devices, see how to sync Markdown notes without a server. Git and a sync folder can be combined, with care, as explained below.
How do you set up Git in a notes folder?
Install Git from git-scm.com or your system's package manager, then run these commands in a terminal, from your notes folder:
cd ~/Notes
git init
git add -A
git commit -m "Initial notes snapshot"
git init creates a hidden .git folder that stores the history. Your notes stay where they are, as ordinary files. Before the first commit, Git may ask you to set a name and email for commit messages:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
These are labels on your commits. They are not an account, and nothing is sent anywhere.
What should a .gitignore for notes include?
A .gitignore file in the notes folder lists files Git should not track. For notes, that means system clutter, app caches and anything large or private you do not want in the history.
# System files
.DS_Store
Thumbs.db
desktop.ini
# Editor and app state that changes constantly
.obsidian/workspace.json
.obsidian/workspace-mobile.json
.vscode/
.trash/
# Large files you keep elsewhere
*.mp4
*.zip
# Private notes that should never leave this computer
private/
Add the .gitignore before your first commit if you can. Git keeps tracking a file it already committed, even if you add it to .gitignore later, until you remove it with git rm --cached <file>.
Which Git commands do you need for notes?
About eight. Everything else is optional.
| Task | Command |
|---|---|
| Save a snapshot of everything | git add -A && git commit -m "Notes for 2026-11-26" |
| See what changed since the last commit | git status and git diff |
| See changes word by word | git diff --word-diff |
| List the history of one note | git log --oneline -- "projects/launch.md" |
| Show every change to one note | git log -p --follow -- "projects/launch.md" |
| Read an old version without changing anything | git show HEAD~5:"projects/launch.md" |
| Restore a note to an older version | git restore --source=HEAD~5 -- "projects/launch.md" |
| Find notes that were deleted | git log --diff-filter=D --name-only --oneline |
git restore overwrites the note in your folder, and edits you have not committed are lost without a prompt, so commit first, or read the old version with git show before you restore it.
--word-diff is the one to remember. Normal diffs compare whole lines, and a Markdown paragraph is often one long line, so changing one word marks the entire paragraph as changed. With --word-diff, Git shows only the words that changed:
The launch moves to [-March-]{+April+} because the store review takes longer.
To bring back a deleted note, find the commit that deleted it, then restore the file from the commit just before:
git log --diff-filter=D --oneline -- "ideas/pricing.md"
# a1b2c3d Remove old ideas
git restore --source=a1b2c3d~1 -- "ideas/pricing.md"
The ~1 means "one commit before", which is the last version where the file existed.
How often should you commit notes?
Once a day is enough for most people. A commit is a checkpoint, and the gaps between checkpoints are what you could lose. If you prefer not to think about it, a scheduled job can commit for you.
On macOS and Linux, add a line to your crontab with crontab -e:
0 21 * * * cd "$HOME/Notes" && git add -A && git commit -q -m "Auto snapshot" || true
That commits every evening at 21:00 if anything changed. || true keeps a day with no changes from counting as a failed job. On Windows, Task Scheduler can run the same git commands from a small batch file.
If you prefer a graphical tool, GitHub Desktop and the Source Control view in VS Code both work on any folder and show diffs side by side. Obsidian users often use the community Obsidian Git plugin, which commits on a timer from inside the app.
Can you use Git and a cloud sync folder together?
You can, but keep the .git folder off the sync service if possible, or sync only from one machine. Cloud drives sync files one by one, and Git's internal files must change together. If two computers write to the same .git folder through a sync service, the repository can end up corrupted.
Two safer setups:
- Git for history, sync for devices. Keep the notes in a cloud folder and run Git on one computer only, with the repository stored outside the synced folder:
git init --separate-git-dir="$HOME/notes-history.git"leaves a small.gitpointer file in the notes folder instead of the full repository. This is the more advanced option. - Git for both. Do not use a sync folder. Each device clones from a private remote and runs
git pullbefore writing andgit pushafter.
If you use Git as your backup, remember that a local repository lives on the same disk as your notes. A pushed remote or a separate backup of the folder covers the disk failing.
What are the limits of Git for notes?
- Merge conflicts. If you edit the same note on two devices before syncing, Git asks you to choose. Conflicts in prose are easy to resolve by hand, but they interrupt you.
- Large binary files. PDFs, images and audio make the repository grow with every version. Keep them out with
.gitignore, or look at Git LFS for large files. - Privacy on remotes. A pushed repository holds every version of every note. Use a private repository, and never commit passwords or keys. Removing something from history later is possible but awkward.
- Mobile. Git apps exist for phones, but the workflow is clumsy compared with a desktop.
Git and Noteline
Noteline, which we make, has no built-in Git or sync, and it does not need to know about Git to work with a repository. Open the notes folder with Open Folder (Cmd+O on a Mac, Ctrl+O on Windows and Linux), and the sidebar shows your notes while hidden folders such as .git are skipped. When a git pull or git restore changes files, the desktop app picks up the new and changed notes. If the note you have open changed on disk, a bar offers Use disk version or Keep my version, so a restore never silently overwrites what you are typing. More on where files live is on where Noteline notes are stored.