Skip to content

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:

python -m pip install GitPython semver
  • A local Git repository (initialize with git init if needed)

Usage

  1. Save the script to your local machine (e.g., git_helper.py).
  2. Open a terminal and navigate to your repository directory.
  3. Run the script:
    python git_helper.py
    
  4. Follow the interactive prompts to:
  5. Stage files
  6. Enter a commit message
  7. Push changes (optional)
  8. Bump version and tag (optional)
  9. 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.

References

grinntec/git-helper