{"id":13625943,"url":"https://github.com/mhagger/git-when-merged","last_synced_at":"2025-04-13T11:48:23.339Z","repository":{"id":6726599,"uuid":"7972465","full_name":"mhagger/git-when-merged","owner":"mhagger","description":"Determine when a particular commit was merged into a git branch","archived":false,"fork":false,"pushed_at":"2023-08-06T07:59:58.000Z","size":82,"stargazers_count":439,"open_issues_count":0,"forks_count":26,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-15T09:32:50.319Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mhagger.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-02-02T06:08:12.000Z","updated_at":"2025-02-28T03:44:25.000Z","dependencies_parsed_at":"2024-06-11T17:14:32.386Z","dependency_job_id":null,"html_url":"https://github.com/mhagger/git-when-merged","commit_stats":{"total_commits":77,"total_committers":10,"mean_commits":7.7,"dds":"0.20779220779220775","last_synced_commit":"67278dc1140b4e7509c5a6873cfd08c415d937fc"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhagger%2Fgit-when-merged","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhagger%2Fgit-when-merged/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhagger%2Fgit-when-merged/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mhagger%2Fgit-when-merged/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mhagger","download_url":"https://codeload.github.com/mhagger/git-when-merged/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248710411,"owners_count":21149186,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:02:06.255Z","updated_at":"2025-04-13T11:48:23.313Z","avatar_url":"https://github.com/mhagger.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# `git when-merged`\n\n`git when-merged` helps you figure out when and why a commit was merged into a branch.\n\nIf you use standard Git workflows, then you create a feature branch for each feature that you are working on. When the feature is complete, you merge it into your `master` branch. You might even have sub-feature branches that are merged into a feature branch before the latter is merged.\n\nIn such a workflow, the first-parent history of `master` consists mainly of merges of feature branches into the mainline. `git when-merged` can be used to ask, \"When (and why) was commit C merged into the current branch?\" The simplest way to use it is\n\n```ShellSession\n$ git when-merged 87c248f\nrefs/heads/master                      50f577451448a407ee8e78ed62aa09d209c91652\n```\n\nThis command looks along the first-parent history of the current branch to find the merge commit that first brought commit `87c248f` into the branch's history. The guilty merge commit in this case is `50f5774`. Add the `-l` option to see the log for that merge, which will hopefully explain what feature was being merged and by whom:\n\n```ShellSession\n$ git when-merged -l 87c248f\nrefs/heads/master                      50f577451448a407ee8e78ed62aa09d209c91652\ncommit 50f577451448a407ee8e78ed62aa09d209c91652 (github/master, master)\nMerge: f79a45d 87c248f\nAuthor: Michael Haggerty \u003cmhagger@alum.mit.edu\u003e\nDate:   Mon Jul 11 07:55:19 2016 +0200\n\n    Merge pull request #9 from mhagger/recursive-option\n\n    Add a `--recursive`/`-r` option\n```\n\nThere are many more options; see below.\n\n\n## Installation\n\n**_Note: If you are using 2.6 \u003c= Python \u003c= 3.6, you MUST use Option 3 or 4._**\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003ch3\u003eOption 1: Install as a stand-alone command line tool.\u003c/h3\u003e\u003c/summary\u003e\n\u003cbr\u003e\n\n\u003e pipx is a tool to help you install and run end-user applications written in Python.\n\n1. [Install `pipx`](https://pipxproject.github.io/pipx/installation/):\n\n   ``` sh\n   python3 -m pip install --user pipx\n   ```\n\n   - Tip: [Homebrew](https://formulae.brew.sh/formula/pipx) as well as newer versions of some Linux distributions (e.g. [Debian 10](https://packages.debian.org/buster/pipx), [Ubuntu 19.04](https://packages.ubuntu.com/disco/pipx), etc.) offer native packages for `pipx`.\n\n   \u003cbr\u003e\n\n   ``` sh\n   python3 -m pipx ensurepath\n   ```\n\n   - Note: You may need to restart your terminal for the `$PATH` updates to take effect.\n\n2. Use `pipx` to install [`git-when-merged` from PyPI](https://pypi.org/project/git-when-merged/):\n\n   ``` sh\n   pipx install git-when-merged\n   ```\n\n3. Test the installation:\n\n   ``` sh\n   git-when-merged --help\n   ```\n\n- Use `pipx` to uninstall at any time:\n\n   ``` sh\n   pipx uninstall git-when-merged\n   ```\n\nSee Python's [Installing stand alone command line tools](https://packaging.python.org/guides/installing-stand-alone-command-line-tools/) guide for more information.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eOption 2: Create an ephemeral installation.\u003c/h3\u003e\u003c/summary\u003e\n\u003cbr\u003e\n\n\u003e Python \"Virtual Environments\" allow Python packages to be installed in an isolated location for a particular application, rather than being installed globally.\n\n1. Use the built-in [`venv`](https://docs.python.org/3/library/venv.html) module to create a virtual environment:\n\n   ``` sh\n   python3 -m venv ./venv-gwm\n   ```\n\n2. Use `pip` to install [`git-when-merged` from PyPI](https://pypi.org/project/git-when-merged/) into the virtual environment:\n\n   ``` sh\n   venv-gwm/bin/pip install git-when-merged\n   ```\n\n3. Test the installation:\n\n   ``` sh\n   venv-gwm/bin/git-when-merged --help\n   ```\n\n   - Tip: Some users find it more convenient to \"activate\" the virtual environment (which prepends the virtual environment's `bin/` to `$PATH`):\n\n      ``` sh\n      source venv-gwm/bin/activate\n      git-when-merged --help\n      deactivate\n      ```\n\n- Remove the virtual environment to uninstall at any time:\n\n   ``` sh\n   rm --recursive venv-gwm/\n   ```\n\nSee Python's [Installing Packages](https://packaging.python.org/tutorials/installing-packages/) tutorial for more information.\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eOption 3: Clone and add to \u003ccode\u003e$PATH\u003c/code\u003e.\u003c/h3\u003e\u003c/summary\u003e\n\u003cbr\u003e\n\n1. Clone the repo somewhere on your system.\n\n2. Ensure that `\u003csomewhere\u003e/bin/git-when-merged` is executable.\n\n3. Put the contents of `\u003csomewhere\u003e/bin` on your `$PATH`.\n\nThat's it!\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch3\u003eOption 4 (MacOS Users): Install from Homebrew.\u003c/h3\u003e\u003c/summary\u003e\n\u003cbr\u003e\n\n```ShellSession\n$ brew update\n$ brew install git-when-merged\n```\n\u003c/details\u003e\n\n## Usage\n\n    git when-merged [OPTIONS] COMMIT [BRANCH...]\n\nFind the merge commit that brought `COMMIT` into the specified `BRANCH`(es). Specifically, look for the oldest commit on the first-parent history of each `BRANCH` that contains the `COMMIT` as an ancestor.\n\n```\npositional arguments:\n  commit                The commit whose destiny you would like to determine.\n  branch                The destination branch(es) into which \u003ccommit\u003e might\n                        have been merged. (Actually, BRANCH can be an\n                        arbitrary commit, specified in any way that is\n                        understood by git-rev-parse(1).) If neither \u003cbranch\u003e\n                        nor --pattern/-p nor --default/-s is specified, then\n                        HEAD is used.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --pattern PATTERN, -p PATTERN\n                        Show when COMMIT was merged to the references matching\n                        the specified regexp. If the regexp has parentheses\n                        for grouping, then display in the output the part of\n                        the reference name matching the first group.\n  --name NAME, -n NAME  Show when COMMIT was merged to the references matching\n                        the configured pattern(s) with the given name (see\n                        whenmerged.\u003cname\u003e.pattern below under CONFIGURATION).\n  --default, -s         Shorthand for \"--name=default\".\n  --recursive, -r       Follow merges back recursively.\n  --show-commit, -c     Display only the SHA-1 of the merge commit. Exit with\n                        a nonzero exit code if the commit was not merged via a\n                        merge commit.\n  --show-branch, -b     Display the range of commits that were merged at the\n                        same time as the specified commit. Exit with a nonzero\n                        exit code if the commit was not merged via a merge\n                        commit. This option also affects the behavior of --log\n                        and --visualize.\n  --abbrev N            Abbreviate commit SHA-1s to the specified number of\n                        characters (or more if needed to avoid ambiguity). See\n                        also whenmerged.abbrev below under CONFIGURATION.\n  --no-abbrev           Do not abbreviate commit SHA-1s.\n  --describe            Describe the merge commit in terms of the most recent\n                        tag reachable from the commit (see git-describe(1))\n  --describe-contains   Describe the merge commit in terms of a nearby tag\n                        that contains it (see git-describe(1))\n  --log, -l             Show the log for the merge commit. When used with\n                        \"--show-branch/-b\", show the log for all of the\n                        commits that were merged at the same time as the\n                        specified commit.\n  --diff, -d            Show the diff for the merge commit.\n  --visualize, -v       Visualize the merge commit using gitk. When used with\n                        \"--show-branch/-b\", only show the branch(es) that were\n                        merged at the same time as the specified commit.\n\nExamples:\n  git when-merged 0a1b                   # Find the merge commit that brought\n                                         # commit 0a1b into the current branch\n  git when-merged 0a1b v1.10 v1.11       # Find merge into given tags/branches\n  git when-merged 0a1b -p feature-[0-9]+ # Specify tags/branches by regex\n  git when-merged 0a1b -n releases       # Use whenmerged.releases.pattern\n  git when-merged 0a1b -s                # Use whenmerged.default.pattern\n\n  git when-merged -r 0a1b                # If the commit was merged indirectly,\n                                         # show each intermediate merge.\n  git when-merged -l 0a1b                # Show the log for the merge commit\n  git when-merged -lb 0a1b               # Show log for the whole merged branch\n  git when-merged -v 0a1b                # Visualize the merge commit in gitk\n  git when-merged -vb 0a1b               # Visualize the whole merged branch\n  git when-merged -d 0a1b                # Show the diff for the merge commit\n  git when-merged -c 0a1b                # Print only the merge's SHA-1\n\nConfiguration:\n  whenmerged.\u003cname\u003e.pattern\n      Regular expressions that match reference names for the pattern\n      called \u003cname\u003e.  A regexp is sought in the full reference name,\n      in the form \"refs/heads/master\".  This option can be multivalued, in\n      which case references matching any of the patterns are considered.\n      Typically the pattern will be chosen to match master and/or significant\n      release branches or tags, or perhaps their remote-tracking equivalents.\n      For example,\n\n          git config whenmerged.default.pattern '^refs/heads/master$'\n          git config --add whenmerged.default.pattern '^refs/heads/maint$'\n\n      or\n\n          git config whenmerged.releases.pattern '^refs/tags/release-'\n\n  whenmerged.abbrev\n      If this value is set to a positive integer, then Git SHA-1s are\n      abbreviated to this number of characters (or longer if needed to\n      avoid ambiguity).  This value can be overridden using --abbrev=N\n      or --no-abbrev.\n```\n\n`git when-merged` is originally based on [the suggestion here](http://stackoverflow.com/questions/8475448/find-merge-commit-which-include-a-specific-commit).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhagger%2Fgit-when-merged","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmhagger%2Fgit-when-merged","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmhagger%2Fgit-when-merged/lists"}