Git Helper Script: Version Bump & Changelog Automation¶
This guide explains how to use a Python script to automate common Git tasks: staging changes, committing, pushing, bumping version numbers, and updating a changelog. It is designed for technical users but assumes no prior experience with automation scripts.
Features¶
- Detect and List Changes: Shows changed and untracked files in your repository.
- Interactive Staging: Lets you choose which files to add to the next commit.
- Commit Changes: Prompts for a commit message and commits staged files.
- Push to Remote: Optionally pushes your commit to the remote repository.
- Version Bumping: Optionally bumps the version (major, minor, or patch) and creates a Git tag.
- Changelog Update: Updates or creates
CHANGELOG.md
with details of changes, new version, and date. - Changelog Commit: Commits the updated changelog file.
Requirements¶
- Python 3.x installed on your system
- The following Python packages:
GitPython
(for interacting with Git)semver
(for version management)
Install these packages using pip:
- A local Git repository (initialize with
git init
if needed)
Usage¶
- Save the script to your local machine (e.g.,
git_helper.py
). - Open a terminal and navigate to your repository directory.
- Run the script:
- Follow the interactive prompts to:
- Stage files
- Enter a commit message
- Push changes (optional)
- Bump version and tag (optional)
- Update and commit the changelog
Notes¶
- Make sure you review the changes before committing or tagging to avoid unintended updates.
- The script is interactive and will guide you through each step.
- For more advanced usage, review the script source and customize as needed.