Skip to content

About

A robust, production-ready command-line tool that automates git push operations safely.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

Repository files navigation

GitAutoPusher

Python Version License

A robust, production-ready command-line tool that automates git push operations safely.

Features

  • 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 subprocess with shell=False to prevent command injection.
    • Supports Authentication via SSH Keys or HTTPS tokens.

Installation

  1. Clone this repository:
    git clone https://github.com/yourusername/git-auto-pusher.git
    cd git-auto-pusher
  2. Install the package:
    pip install -e .

Usage

Interactive Mode

Simply run the command without any arguments:

git-autopush

You will be greeted with a menu:

  1. Push a file/directory: Prompts for path, repo URL, credentials (if needed), and commit message.
  2. Configure defaults: Saves default path, URL, and username to ~/.autopushrc (tokens are NEVER saved).
  3. Show status: Displays current saved defaults.

Non-Interactive (Command Line) Mode

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"

Security Best Practices

  • 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.

Troubleshooting

  • Authentication Failed: Ensure your Personal Access Token has repo scope. 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.

Contributing

Contributions are welcome! Please open an issue or submit a pull request with any improvements. Run tests using pytest.

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

A robust, production-ready command-line tool that automates git push operations safely.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages