Prerequisites
Git must be installed on your system. Scratch will automatically detect if git is available.Enabling Git
Git integration is completely optional and can be enabled from Settings.- Open Settings (
Cmd+,orCtrl+,) - Go to the General tab
- Under Version Control, click Initialize Git Repository
git init in your notes folder and begins tracking changes.
Git Operations
Once enabled, Scratch exposes git operations through the sidebar and settings.Commit Changes
The sidebar displays a floating git status indicator showing:- Current branch name
- Number of changed files
- Number of commits ahead/behind remote
- Click the git status indicator in the sidebar
- Enter a commit message
- Click Commit
Connect a Remote
To enable multi-device sync, connect a remote repository:- Create a repository on GitHub, GitLab, or any git hosting service
- Copy the repository URL (HTTPS or SSH)
- In Settings → General → Version Control, click Add Remote
- Paste the URL and click Connect
Supported URL formats:
- HTTPS:
https://github.com/username/my-notes.git - SSH:
[email protected]:username/my-notes.git
Push and Pull
Once a remote is connected: First Push: For the initial push, Scratch will set up upstream tracking:- Push - Sends your commits to the remote
- Pull - Fetches and merges remote changes
Multi-Device Sync
With a remote connected, you can sync notes across multiple devices:- Device A: Make changes, commit, and push
- Device B: Pull to receive changes
- Repeat as needed
Git Status
The git status indicator shows real-time information:- Branch name: Current branch (usually
mainormaster) - Changed files: Uncommitted changes in your notes folder
- Ahead count: Commits waiting to be pushed
- Behind count: Commits available to pull
- Remote URL: Connected repository
- Upstream tracking: Whether the current branch tracks a remote branch
Commands Reference
Scratch exposes these git operations through the Rust backend:| Operation | Git Command | Description |
|---|---|---|
| Initialize | git init | Create a new git repository |
| Status | git status --porcelain | Get current status |
| Commit | git add -A && git commit -m "..." | Stage and commit all changes |
| Push | git push | Push commits to remote |
| Pull | git pull --no-rebase | Fetch and merge remote changes |
| Fetch | git fetch --quiet | Update remote tracking refs |
| Add Remote | git remote add origin <url> | Connect a remote repository |
| Push with Upstream | git push -u origin <branch> | Push and set upstream tracking |
Error Handling
Scratch provides user-friendly error messages for common git issues: Authentication FailedImplementation Details
Git integration is implemented insrc-tauri/src/git.rs using Rust’s std::process::Command to execute git CLI commands. The implementation includes:
- Git availability detection
- Repository status tracking
- Remote configuration management
- Upstream tracking detection
- Error parsing and user-friendly messages
- Timeout configuration for network operations
Scratch uses the git CLI directly rather than a git library (like libgit2) to ensure maximum compatibility and feature parity with standard git workflows.
Best Practices
- Commit frequently: Small, focused commits are easier to manage
- Write descriptive messages: Explain why changes were made, not just what changed
- Pull before pushing: Reduces merge conflicts on multi-device setups
- Use SSH for authentication: More secure than HTTPS with credentials
- Keep notes folder focused: Avoid mixing notes with other files
Disabling Git
Git integration is non-intrusive. If you don’t initialize a repository, Scratch operates in pure local mode with no git overhead. Even with git enabled, all operations are manual - nothing happens automatically. To stop using git, simply remove the.git folder from your notes directory. Scratch will detect this and disable git features.