A robust, production-ready command-line tool that automates git push operations safely.
- Interactive CLI Menu: Easy-to-use menu for pushing files, configuring defaults, and checking status.
- Automatic Error Handling & Self-Fixing:
- Automatically initializes new git repositories if needed.
- Catches and handles detached HEAD states.
- Detects and warns about large files (>50MB).
- Retries network operations with exponential backoff.
- Stashes local uncommitted changes before pulling (to avoid conflicts), then unstashes.
- Strict Security:
- Never stores passwords or tokens on disk.
- Masks credential inputs using
getpass. - Uses
subprocesswithshell=Falseto prevent command injection. - Supports Authentication via SSH Keys or HTTPS tokens.
- Clone this repository:
git clone https://github.com/yourusername/git-auto-pusher.git cd git-auto-pusher - Install the package:
pip install -e .
Simply run the command without any arguments:
git-autopushYou will be greeted with a menu:
- Push a file/directory: Prompts for path, repo URL, credentials (if needed), and commit message.
- Configure defaults: Saves default path, URL, and username to
~/.autopushrc(tokens are NEVER saved). - Show status: Displays current saved defaults.
Useful for scripts or CI environments. Requires environment variables for authentication.
export GITHUB_USER="your_username"
export GITHUB_TOKEN="your_personal_access_token"
git-autopush --non-interactive --path ./my_project --url https://github.com/username/repo.git -m "Automated commit"Or for SSH:
export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa -o IdentitiesOnly=yes"
git-autopush --non-interactive --path ./my_project --url git@github.com:username/repo.git -m "Automated commit"- Never commit tokens: The configuration system (
~/.autopushrc) strictly strips tokens before saving. - Use Personal Access Tokens (PATs) instead of passwords when using HTTPS.
- Use SSH keys protected by a passphrase for maximum security.
- Authentication Failed: Ensure your Personal Access Token has
reposcope. If using SSH, ensure the correct key is loaded in your SSH agent or provided via the menu. - Network Error: The tool will automatically retry up to 3 times. Check your internet connection if it persistently fails.
- Merge Conflict after Unstashing: If local uncommitted changes conflict with remote changes during a
pull --rebase, you will be warned to resolve them manually.
Contributions are welcome! Please open an issue or submit a pull request with any improvements. Run tests using pytest.
This project is licensed under the MIT License - see the LICENSE file for details.