Skip to main content

Analyze git branches to find unmerged commits

Project description

Git Unmerged

A Python command-line tool to analyze git branches and find commits that haven't been merged into a base branch.

Features

  • Find all branches with recent commits (configurable time window)
  • Identify branches not yet merged into a base branch (e.g., dev, main)
  • Filter branches by ignore patterns
  • Configurable base branch, time window, and ignore patterns
  • Clean, tabular output showing unmerged commit counts

Installation

From source

cd /c/tmp/git-unmerged
pip install .

Development installation

cd /c/tmp/git-unmerged
pip install -e .

Usage

Basic usage (analyze current directory)

git-unmerged

Analyze a specific repository

git-unmerged --repo /path/to/repo

Compare against a different base branch

git-unmerged --base-branch origin/main

Change the ignore pattern

# Ignore branches containing 'hotfix'
git-unmerged --ignore-pattern hotfix

# Don't ignore any branches
git-unmerged --ignore-pattern ""

Look back a different number of days

# Look back 90 days instead of the default 60
git-unmerged --days 90

Skip fetching from remote

git-unmerged --no-fetch

Combined example

git-unmerged \
  --repo /path/to/eld-system-mobile \
  --base-branch origin/dev \
  --ignore-pattern "-eld" \
  --days 60

Command-line Options

Option Default Description
--repo . (current directory) Path to the git repository
--base-branch origin/dev Base branch to compare against
--ignore-pattern -eld Pattern to ignore in branch names (use "" to disable)
--days 60 Number of days to look back for recent commits
--no-fetch False Skip fetching from remote
--version - Show version and exit
--help - Show help message and exit

Output Example

Fetching latest changes from remote...

Finding branches with commits in the last 60 days...
Ignoring branches containing: '-eld'

Found 22 branches NOT merged into origin/dev:

Branch Name                                                  Commits    Last Commit Date
----------------------------------------------------------------------------------------------------
feat/timing-compliance                                       15         2025-11-21 23:25:02 +0500
feature/set_event_to_doc_activity                            1          2025-11-21 21:49:45 +0500
hotfix/improve-split-sleep                                   2          2025-11-21 20:27:51 +0500
...


Total unmerged branches: 22

Use as a Python Module

You can also use the analyzer programmatically:

from git_unmerged.analyzer import GitUnmerged

analyzer = GitUnmerged(
    repo_path='/path/to/repo',
    base_branch='origin/dev',
    ignore_pattern='-eld',
    days=60
)

unmerged_branches = analyzer.analyze(fetch=True)

for branch in unmerged_branches:
    print(f"{branch['name']}: {branch['unmerged_commits']} commits")

Requirements

  • Python 3.7 or higher
  • Git installed and available in PATH

License

MIT License

Contributing

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_unmerged-1.0.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_unmerged-1.0.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file git_unmerged-1.0.0.tar.gz.

File metadata

  • Download URL: git_unmerged-1.0.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for git_unmerged-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8efced72396c769fd15a146f0381a66da0740f923e8a902268108b65c8daf94c
MD5 65f30d67d853ca32cafee22dd4e7e491
BLAKE2b-256 c500572c0845e8ac7e3a135b4dc589b837f75fc7b78770946fa976354d57c432

See more details on using hashes here.

File details

Details for the file git_unmerged-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: git_unmerged-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for git_unmerged-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 777079d110977ccfff21970a3de68761eb494a354c99796b0504c0732d030975
MD5 07688bd7ac90491b6ce20a171c0976cf
BLAKE2b-256 db93751e59dc7a75c3363a8017a11e93918417d10746cd32e3f7de0aa0667258

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page