simple-git-manager
v1.0.0
Published
Cross-platform Git automation with auto-startup
Maintainers
Readme
Simple Git Manager - Cross-Platform Auto-Sync
A lightweight Git automation tool that works on laptops, phones, and desktops with automatic startup and intelligent sync workflow.
✨ Key Features
- 🔄 Smart Sync Workflow: Pull → Commit → Push automatically
- 📁 Multi-vault tracking - Monitor multiple folders
- 📱 Cross-Platform: Windows, macOS, Linux, Android (via Termux)
- 🚀 Auto-Startup: Starts automatically when device boots
- ⏰ Periodic Sync: Automatic sync every 30 minutes
- 🎯 Conflict Resolution: Intelligent stashing and merging
- ⚙️ Configurable Git Operations: Custom commit messages, delays, and patterns
- 📊 Real-time Monitoring: Track all Git operations
- 🎯 Smart File Filtering: Include/exclude patterns using glob syntax
- 🌐 Optional web UI: Manage vaults through browser
- 🔧 Standalone Operation: Works without web interface for headless servers
🚀 Quick Setup
1. Install Dependencies
```bash npm install ```
2. Install as System Service (Auto-Startup)
```bash
Install auto-startup service
npm run install-service
Start immediately
npm start ```
3. Add Your First Vault
```bash
Add Obsidian vault with auto-sync
npm run cli add \ -n "My Notes" \ -p "/path/to/obsidian-vault" \ -r "https://github.com/username/notes.git"
Add project folder
npm run cli add \ -n "My Project" \ -p "/path/to/project" \ -r "[email protected]:username/project.git" ```
📱 Platform-Specific Setup
🖥️ Windows
```bash
Install Node.js from nodejs.org
Clone and setup
git clone cd simple-git-manager npm install npm run install-service ```
🍎 macOS
```bash
Install Node.js via Homebrew
brew install node
Setup
git clone cd simple-git-manager npm install npm run install-service ```
🐧 Linux
```bash
Install Node.js
sudo apt install nodejs npm # Ubuntu/Debian
or
sudo dnf install nodejs npm # Fedora
Setup
git clone cd simple-git-manager npm install npm run install-service ```
📱 Android (Termux)
```bash
Install Termux from F-Droid or Play Store
In Termux:
pkg install nodejs git git clone cd simple-git-manager npm install
Setup auto-start (add to ~/.bashrc)
echo "cd ~/simple-git-manager && npm start &" >> ~/.bashrc ```
🔄 Smart Sync Workflow
The application follows this intelligent workflow:
- 📥 Initial Pull: On startup, pull latest changes from all remotes
- 👀 File Watching: Monitor file changes in real-time
- 🔄 Auto-Sync on Changes:
- Pull latest changes (with stashing if needed)
- Commit local changes
- Push to remote
- ⏰ Periodic Sync: Every 30 minutes, sync all vaults
- 🔧 Conflict Resolution: Automatic stashing and merging
🎯 Usage Options
1. CLI Commands (Recommended)
```bash
Vault Management
npm run cli add -n "Name" -p "/path" -r "remote-url" npm run cli list npm run cli remove
Manual Operations
npm run cli commit npm run cli push npm run cli pull
Service Management
npm run cli start # Start daemon npm run cli start --no-web # Headless mode npm run install-service # Install auto-startup npm run uninstall-service # Remove auto-startup
Status & Monitoring
npm run cli status ```
2. Programmatic API
```javascript const SimpleGitManager = require('./src/index')
const manager = new SimpleGitManager() await manager.start()
// Add vault await manager.addVault({ name: 'My Project', path: '/path/to/folder', remote_url: 'https://github.com/user/repo.git', auto_commit: true, auto_push: true, auto_pull: true })
// Manual operations await manager.commitVault(vaultId) await manager.pushVault(vaultId) await manager.pullVault(vaultId) ```
3. Web Interface
Access the web dashboard at http://localhost:3000:
- 📊 Dashboard: View all vaults and their status
- ➕ Add Vaults: Create new vaults through UI
- 🔄 Manual Operations: Commit, push, pull buttons
- 📝 Activity Log: Real-time operation history
- ⚙️ Settings: Configure sync intervals and options
4. Headless Mode
```bash
Start without web interface
npm run cli start --no-web ```
🔧 Configuration
Auto-Generated Config (git-manager-config.json)
```json { "vaults": [ { "id": "uuid", "name": "My Vault", "path": "/absolute/path", "remote_url": "https://github.com/user/repo.git", "branch": "main", "auto_commit": true, "auto_push": true, "auto_pull": true, "enabled": true, "commit_delay": 5000, "include_patterns": "/*", "exclude_patterns": ".git/,node_modules/**,*.tmp" } ] } ```
Environment Variables
```env PORT=3000 # Web interface port WEB_ENABLED=true # Enable/disable web interface LOG_LEVEL=info # Logging level SYNC_INTERVAL=30 # Sync interval in minutes CONFIG_PATH=./git-manager-config.json # Configuration file path ```
File Patterns
Use glob patterns for include/exclude rules:
**/*- All files and directories*.md- All Markdown files**/*.js- All JavaScript files recursively.git/**- Exclude Git directorynode_modules/**- Exclude Node.js modules*.tmp,*.log- Exclude temporary and log files
Commit Message Templates
Use placeholders in commit messages:
{timestamp}- Current timestamp{filesChanged}- Number of files changed{files}- List of changed files
Example: Auto-commit: {filesChanged} files changed at {timestamp}
📡 API Endpoints (Web Interface)
Vaults
GET /api/vaults- List all vaultsPOST /api/vaults- Create new vaultGET /api/vaults/:id- Get vault detailsPUT /api/vaults/:id- Update vaultDELETE /api/vaults/:id- Delete vaultPOST /api/vaults/:id/commit- Manual commitPOST /api/vaults/:id/push- Manual pushPOST /api/vaults/:id/pull- Manual pull
System
GET /api/status- System statusGET /api/logs- Activity logsGET /health- Health check
🛠️ Development
```bash
Development mode with auto-reload
npm run dev
Run CLI commands
npm run cli ```
Project Structure
``` src/ ├── core/ │ ├── git-manager.js # Main Git automation logic │ ├── file-watcher.js # File system monitoring │ └── config-manager.js # Configuration management ├── routes/ │ ├── vaults.js # Vault API endpoints │ ├── status.js # Status endpoints │ └── logs.js # Logging endpoints ├── utils/ │ └── logger.js # Winston logging setup └── index.js # Application entry point ```
🔒 Security & Authentication
Git Authentication Setup
HTTPS with Token: ```bash
GitHub Personal Access Token
git config --global credential.helper store
Then use: https://username:[email protected]/user/repo.git
```
SSH Keys: ```bash
Generate SSH key
ssh-keygen -t ed25519 -C "[email protected]"
Add to GitHub/GitLab
cat ~/.ssh/id_ed25519.pub
Use SSH URL: [email protected]:user/repo.git
```
🔍 Troubleshooting
Common Issues
Permission Errors ```bash
Fix file permissions
chmod -R 755 /path/to/vault ```
Git Authentication ```bash
Test Git access
git ls-remote https://github.com/user/repo.git ```
Service Not Starting ```bash
Check service status (Linux)
systemctl --user status simple-git-manager
Restart service
npm run uninstall-service npm run install-service ```
File Watching Limits (Linux) ```bash
Increase inotify limits
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf sudo sysctl -p ```
Android/Termux Specific
```bash
Grant storage permissions
termux-setup-storage
Install required packages
pkg install nodejs git openssh
Setup SSH for Git
ssh-keygen -t ed25519 ```
🚀 Advanced Usage
Multiple Device Sync
Setup on Device 1: ```bash npm run cli add -n "Shared Notes" -p "/path/to/notes" -r "repo-url" ```
Setup on Device 2: ```bash
Clone the repo first
git clone repo-url /path/to/notes
Add to Git Manager
npm run cli add -n "Shared Notes" -p "/path/to/notes" -r "repo-url" ```
Both devices will now auto-sync!
Custom Sync Intervals
```bash
Sync every 10 minutes
SYNC_INTERVAL=10 npm start
Disable periodic sync (only on file changes)
SYNC_INTERVAL=0 npm start ```
📝 License
MIT License - Use freely for personal and commercial projects.
Simple Git Manager - Keep your files in sync across all your devices! 🚀📱💻
