Package Exports
- @sbeeredd04/auto-git
- @sbeeredd04/auto-git/bin/auto-git.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sbeeredd04/auto-git) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Auto-Git 🤖
AI-powered automatic Git commits with Gemini-generated commit messages
Auto-Git is a cross-platform CLI tool that watches your files and automatically generates meaningful commit messages using Google's Gemini AI, then commits and pushes your changes.
✨ Features
- 🤖 AI-Generated Commit Messages: Uses Google Gemini to create conventional, meaningful commit messages
- 👀 File Watching: Automatically detect changes and commit them
- 🚀 One-Shot Commits: Manual commit generation for current changes
- 🔧 Cross-Platform: Works on Windows, macOS, and Linux
- ⚙️ Configurable: Environment variables and user config support
- 🎯 Smart Debouncing: Prevents spam commits during rapid file changes
- 📦 Zero Config: Works out of the box with just an API key
🚀 Quick Start
1. Install Dependencies
npm install2. Get a Gemini API Key
- Visit Google AI Studio
- Create a new API key
- Set it as an environment variable:
export GEMINI_API_KEY="your-api-key-here"3. Use Auto-Git
One-time commit:
# Link the tool locally
npm link
# Commit current changes
auto-git commitWatch mode (continuous):
auto-git watch📖 Usage
Commands
auto-git commit (or auto-git c)
Generates an AI commit message for current changes and commits/pushes them.
auto-git commit # Commit and push current changes
auto-git commit --no-push # Commit but don't push
auto-git commit --dry-run # Preview what would be committed (coming soon)auto-git watch
Starts file watching mode - automatically commits changes when files are modified.
auto-git watch # Watch current directory
auto-git watch --paths src lib # Watch specific directories
auto-git watch --no-push # Watch and commit but don't pushauto-git config
Shows current configuration and setup status.
auto-git configauto-git setup
Interactive setup guide.
auto-git setupConfiguration
Auto-Git supports multiple configuration methods (in order of priority):
Environment Variables
export GEMINI_API_KEY="your-key" export AUTO_GIT_WATCH_PATHS="src,lib,docs" export AUTO_GIT_DEBOUNCE_MS="3000"
User Config File (
~/.auto-gitrc.json){ "apiKey": "your-gemini-api-key", "watchPaths": ["src", "lib"], "debounceMs": 2000 }
.envFile (in your project)GEMINI_API_KEY=your-key
🔧 Installation Options
Option 1: Local Development
git clone <this-repo>
cd auto-git
npm install
npm linkOption 2: Global Installation (if published to npm)
npm install -g auto-gitOption 3: Direct from Git
npm install -g git+https://github.com/yourusername/auto-git.git🎯 How It Works
- File Detection: Monitors file changes using
chokidar - Change Analysis: Runs
git diffto understand what changed - AI Processing: Sends changes to Gemini AI for commit message generation
- Git Operations: Automatically runs
git add .,git commit, andgit push
Generated Commit Messages
Auto-Git generates conventional commit messages following best practices:
- ✅
feat(auth): add user login validation - ✅
fix(api): resolve null pointer exception - ✅
docs(readme): update installation steps - ✅
refactor(utils): simplify date formatting
🛡️ Security & Privacy
- ✅ No secrets in repos: API keys are never committed to your repository
- ✅ User-specific config: Each user manages their own API key
- ✅ Local processing: Only diffs are sent to Gemini API
- ✅ Optional pushing: Can commit locally without pushing
🎛️ Advanced Usage
Custom Watch Paths
auto-git watch --paths src components libEnvironment-Specific Config
# Development
export GEMINI_API_KEY="dev-key"
auto-git watch --paths src
# Production
export GEMINI_API_KEY="prod-key"
auto-git commit --no-pushDebounce Configuration
Prevent too many commits during rapid changes:
// ~/.auto-gitrc.json
{
"debounceMs": 5000, // Wait 5 seconds after last change
"apiKey": "your-key"
}🚨 Important Notes
- Ensure you're in a Git repository before running
- Configure your Git user name and email:
git config --global user.name "Your Name" - Test in a non-critical repository first
- Review generated commits periodically to ensure quality
🛠️ Development
Project Structure
auto-git/
├── bin/auto-git.js # CLI entrypoint
├── lib/
│ ├── config.js # Configuration management
│ ├── gemini.js # Gemini API integration
│ ├── git.js # Git operations
│ └── watcher.js # File watching logic
├── package.json
└── README.mdTesting Locally
# Install dependencies
npm install
# Link for local testing
npm link
# Test commands
auto-git config
auto-git commit🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
📝 License
MIT License - see LICENSE file for details.
🆘 Troubleshooting
Common Issues
"Not a git repository"
- Ensure you're running the command inside a Git repository
- Run
git initif needed
"GEMINI_API_KEY not found"
- Set your API key:
export GEMINI_API_KEY="your-key" - Or create
~/.auto-gitrc.jsonwith your key
"Failed to push"
- Ensure you have a remote configured:
git remote -v - Set up upstream:
git push --set-upstream origin main
Too many commits
- Increase debounce time in config
- Use
--no-pushto commit locally only
Debug Mode
DEBUG=auto-git* auto-git watch🎉 Examples
Basic Workflow
# 1. Set up API key
export GEMINI_API_KEY="your-key"
# 2. Start coding...
echo "console.log('Hello World');" > app.js
# 3. Auto commit
auto-git commit
# → Generated: "feat(app): add hello world console output"
# 4. Or start watching
auto-git watch
# → Automatically commits future changesTeam Usage
Each team member sets their own API key, no shared secrets needed:
# Alice
export GEMINI_API_KEY="alice-key"
auto-git watch
# Bob
export GEMINI_API_KEY="bob-key"
auto-git commitHappy coding! 🚀