Why Git for Sync?
- Full version history - Every change is tracked with commit messages
- Works with any Git remote - Not locked into a proprietary service
- Merge conflict handling - Git’s robust merge capabilities
- Works offline - Commit locally, push when connected
- Compatible with other tools - Obsidian Git plugin, Working Copy, etc.
Git sync is optional. If you only use Scratch on one device or prefer cloud storage (Dropbox, iCloud), you don’t need Git.
Prerequisites
Before enabling Git sync:- Install Git - Download from git-scm.com
- Create a remote repository - GitHub, GitLab, or any Git host
- Set up SSH keys (recommended) or HTTPS auth for push/pull
Initial Setup
Step 1: Initialize Git Repository
Step 2: Add Remote Repository
Connect your local repository to a remote:Copy Remote URL
Get the repository URL from your Git host:
- SSH:
[email protected]:username/notes.git - HTTPS:
https://github.com/username/notes.git
Add Remote in Scratch
In the Git status panel (bottom of sidebar), click Add Remote and paste the URL.
SSH vs HTTPS: SSH is recommended for seamless push/pull without password prompts. Set up SSH keys on your Git host first.
Step 3: First Commit and Push
Commit your existing notes and push to the remote:Review Changes
The Git status shows how many files have changed. For a fresh repo, all notes will be “new.”
Daily Workflow
Once set up, syncing is straightforward:On Device A (Making Changes)
- Edit notes as usual - Scratch auto-saves every 500ms
- Commit changes - Write a commit message and click Commit
- Push - Click the Push button (↑) to upload to remote
On Device B (Pulling Changes)
- Pull latest changes - Click the Pull button (↓) in Git status
- Notes auto-reload - Scratch detects file changes and reloads the current note
Git Status Indicators
The Git panel (bottom of sidebar) shows real-time status:| Indicator | Meaning |
|---|---|
| 2 changes | 2 uncommitted files (staged or unstaged) |
| ↑ 3 | 3 commits ahead of remote (need to push) |
| ↓ 1 | 1 commit behind remote (need to pull) |
| origin/main | Current branch and remote |
Git status auto-refreshes when files change (1 second debounce). You don’t need to manually refresh.
Handling Conflicts
If you edited the same note on two devices without syncing:- Pull fails with conflict - Scratch shows an error: “Pull failed due to merge conflicts”
- Resolve manually - Open the notes folder in a terminal or GUI Git client
- Run merge - Use
git pulland resolve conflicts in a text editor - Commit the merge -
git add .andgit commit - Return to Scratch - Click Refresh to reload notes
Advanced: Command Line Workflow
You can mix Scratch with command-line Git for advanced operations:Sync with Multiple Devices
Adding a Second Device
You don’t need to “Initialize Repository” on the second device. Scratch auto-detects existing Git repos.
Troubleshooting
”Authentication failed” Error
SSH: Ensure your SSH key is added to the Git host (GitHub → Settings → SSH Keys). HTTPS: Git may prompt for username/password in the background. Use SSH or a credential helper:“Repository not found”
Check the remote URL:“Could not connect to remote”
Check your internet connection and firewall settings. Test with:Notes Not Reloading After Pull
Scratch uses a file watcher to detect changes. If notes don’t reload:- Press
Cmd+Rto manually reload the current note - Toggle to another note and back
- Restart Scratch if the issue persists
Git Settings Storage
Git configuration is stored in two places:.git/folder - Standard Git metadata (commits, branches, remotes).scratch/settings.json- Scratch-specific settings (gitEnabledflag)
Best Practices
- Commit frequently - Small commits with clear messages are easier to track
- Pull before editing - Especially when switching devices
- Use descriptive commit messages - Future you will thank you
- Don’t commit large binaries - Images in
assets/are fine, but avoid videos or large PDFs - Set up
.gitignore- Exclude OS files (.DS_Store,Thumbs.db)
Example .gitignore
Create.gitignore in your notes folder:
Limitations
- No auto-commit - Scratch doesn’t auto-commit on every save (by design)
- No conflict resolution UI - Use Git CLI or GUI tools for merge conflicts
- No branch switching - Scratch works with your current branch; switch branches externally
- No Git LFS - Large files (>100MB) may cause push failures; use Git LFS if needed
Scratch’s Git integration is intentionally simple. For advanced workflows (rebasing, cherry-picking, submodules), use Git CLI alongside Scratch.