A simple bash script to help sync your Git repositories with their upstreams on GitHub.
I have many repositories that I usually sync (push / pull) on daily basis to ensure my laptop and PC are in sync. These are very basic and common repositories such as my dot files repo, my drafts, documents (all in Markdown), gists, etc.
This script is also part of my automation workflow, you can checkout watchexec
service and my articles on Medium.com for more ideas about my automation workflows.
- ✅ Backup: Auto-commit and push local changes
- 🔄 Pull: Fetch and merge upstream changes
- 🔍 Compare: View local/remote differences
- ➕ Add Repos: Easily track new repositories
- 🎨 Color-coded output for clear status
- 🚀 Bulk operations on all repos at once
-
Install:
git clone https://github.com/hanymamdouh82/syncgit.git -o ~/syncgit chmod +x ~/syncgit/syncgit.sh ~/syncgit/utils.sh PATH=$PATH:$HOME/syncgit
-
Configure:
echo "/path/to/your/repo1" >> ~/syncgit/repos.config echo "/path/to/your/repo2" >> ~/syncgit/repos.config
-
Run:
./syncgit.sh
| Command | Description |
|---|---|
./syncgit.sh |
Interactive mode |
./syncgit.sh b A |
Backup all repos |
./syncgit.sh p 2 |
Pull changes for repo #2 |
./syncgit.sh c A |
Compare all repos |
./syncgit.sh a ~/new-repo |
Add new repository |
| Flag | Operation | Description |
|---|---|---|
b |
Backup | Commit+push local changes |
p |
Pull | Fetch+merge remote changes |
c |
Compare | Show local/remote diff |
a |
Add | Track new repository |
Edit repos.config to manage tracked repositories:
# Format: One path per line
/path/to/repo1
/path/to/repo2
# Comments start with #
- Bash 4.0+
- Git 2.0+
- Coreutils (date, ping, etc.)
Q: How do I see which repos are tracked?
A: View your repos.config file or run compare (c A)
Q: Why won't my changes backup?
A: Backup only runs if you have uncommitted changes AND your local is ahead
Q: How do I reset the config?
A: Simply delete or edit repos.config
This project is licensed under the GNU General Public License v3.0.
By using, distributing, or modifying this software, you agree to the terms in LICENSE.
Key requirements:
- 🛑 Disclose source: Modified versions must be open-sourced under GPL-3.0
- 📜 Include license: All copies must retain this notice
- 🔗 Same license: Derivatives must use GPL-3.0
Full terms: https://www.gnu.org/licenses/gpl-3.0.en.html
Created by Hany Mamdouh - Report issues here