Skip to main content

GitPushAgent

A simple Python package that automates Git push operations with a single function call. Perfect for automating Git workflows and CI/CD pipelines.

Features

  • Simple one-function interface
  • Automatic Git configuration
  • Branch management (create/switch)
  • Repository initialization
  • Error handling
  • Local Git config management

Installation

You can install GitPushAgent using pip:

pip install gitpushagent

Usage

Basic Usage

from gitpushagent import push

# Push to main branch
push(
    username="your-username",
    email="your.email@example.com",
    repo_url="https://github.com/username/repo.git",
    local_path="/path/to/your/local/directory",
    commit_message="Your commit message"
)

Using a Different Branch

from gitpushagent import push

# Push to a specific branch
push(
    username="your-username",
    email="your.email@example.com",
    repo_url="https://github.com/username/repo.git",
    local_path="/path/to/your/local/directory",
    commit_message="Your commit message",
    branch_name="feature-branch"  # Optional, defaults to "main"
)

Error Handling

from gitpushagent import push, GitPushError

try:
    push(
        username="your-username",
        email="your.email@example.com",
        repo_url="https://github.com/username/repo.git",
        local_path="/path/to/your/local/directory",
        commit_message="Your commit message"
    )
except GitPushError as e:
    print(f"An error occurred: {e}")
except ValueError as e:
    print(f"Invalid input: {e}")

Parameters

  • username (str): Your Git username
  • email (str): Your Git email
  • repo_url (str): URL of the public repository
  • local_path (str): Path to the local directory you want to push
  • commit_message (str): Your commit message
  • branch_name (str, optional): Branch name to push to (defaults to "main")

Features in Detail

  1. Automatic Git Configuration: Sets up Git user name and email locally for the operation
  2. Repository Management:
    • Initializes Git repository if not already initialized
    • Adds remote origin if not present
  3. Branch Handling:
    • Creates new branch if it doesn't exist
    • Switches to existing branch if it exists
  4. Smart Push:
    • Only commits if there are changes
    • Pushes to the specified branch
  5. Error Handling:
    • Validates all inputs
    • Provides clear error messages
    • Cleans up local Git config after operation

Requirements

  • Python 3.7 or higher
  • Git installed on your system

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Metadata

Release files for gitpushagent 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitpushagent 0.1.3
File Size Uploaded
gitpushagent-0.1.3.tar.gz 4.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitpushagent 0.1.3
File Interpreter ABI Platform
gitpushagent-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 10.3 kB

Release files / gitpushagent-0.1.3.tar.gz

Download URL gitpushagent-0.1.3.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e9c2f28d1697e4b56772d54824a134acece713dac842add96d0af663aacb3694
BLAKE2b-256 checksum
How to use checksums
6aa3a184c96ef3fd466d8266d2212f9d9e078b4149790a22c26278dd39fd8449
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release files / gitpushagent-0.1.3-py3-none-any.whl

Download URL gitpushagent-0.1.3-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f0137a07f078e405a4530a8ec5bfe9e81313b41957b402d884e8da550b1e0fa5
BLAKE2b-256 checksum
How to use checksums
72c5d7cc9856ee4ee60b450af819a9857e24ba1782758b2fe3d50522f12ef06e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.2

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page