Bidirectional file and directory synchronization across machines using Git and symlinks.
curl -fsSL https://raw.githubusercontent.com/ofrades/ghsync/main/install.sh | bash# Initialize with your repo (SSH recommended)
ghsync init git@github.com:user/dotfiles.git
# Save files or directories you want to sync
ghsync save ~/.bashrc
ghsync save ~/.config/nvim
# Push changes to remote
ghsync sync| Command | Description |
|---|---|
ghsync init <repo> [token] |
Initialize and restore symlinks (token optional for SSH) |
ghsync save <path> |
Save file or directory to repo and create symlink |
ghsync remove <path> |
Stop tracking and restore original |
ghsync sync |
Push/pull changes and restore new symlinks |
ghsync status |
Show local changes and remote sync status |
ghsync restore |
Manually restore all symlinks |
ghsync list |
List all tracked files and directories |
savecopies file/directory to~/.ghsync/repo/, commits locally, replaces original with symlinksyncpushes your commits, pulls remote changes, and restores any new symlinksinitclones the repo and automatically restores all symlinksremoverestores the original file/directory and stops tracking
ghsync init git@github.com:user/dotfiles.gitghsync init https://github.com/user/dotfiles YOUR_TOKENGet a token with 'repo' scope at https://github.com/settings/tokens
Machine 1 (first time):
ghsync init git@github.com:user/dotfiles.git
ghsync save ~/.bashrc
ghsync save ~/.config/nvim
ghsync syncMachine 2 (setup):
ghsync init git@github.com:user/dotfiles.git
# Symlinks are automatically restored!Daily use (any machine):
# Edit files normally (they're symlinks to the repo)
vim ~/.bashrc
# Sync changes
ghsync sync
# Check status without syncing
ghsync status~/.ghsync/
├── config # Repo URL and token
└── repo/ # Git clone
├── manifest.json # Tracked files/directories list
└── ~/
├── .bashrc
└── .config/
└── nvim/ # Entire directory synced
bashgit- Optional:
jq(for better manifest handling)
Run the automated command coverage suite:
bash tests/ghsync_tests.sh- Token stored in
~/.ghsync/config- keep it secure (use SSH to avoid tokens) - Files and directories become symlinks pointing to the repo
- Use
ghsync remove <path>to stop tracking and restore the original