|
1 |
| -Installation |
2 |
| ------------- |
3 |
| -Clone the repo somewhere on your system. |
4 |
| -Ensure that <somewhere>/bin/git-when-merged is executable. |
5 |
| -Put the contents of <somewhere>/bin on your $PATH. That's it! |
| 1 | +# `git when-merged` |
6 | 2 |
|
7 |
| -Or using Homebrew: |
| 3 | +`git when-merged` helps you figure out when and why a commit was merged into a branch. |
8 | 4 |
|
| 5 | +If 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. |
| 6 | + |
| 7 | +In 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 |
| 8 | + |
| 9 | +```ShellSession |
| 10 | +$ git when-merged 87c248f |
| 11 | +refs/heads/master 50f577451448a407ee8e78ed62aa09d209c91652 |
| 12 | +``` |
| 13 | + |
| 14 | +This 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: |
| 15 | + |
| 16 | +```ShellSession |
| 17 | +$ git when-merged -l 87c248f |
| 18 | +refs/heads/master 50f577451448a407ee8e78ed62aa09d209c91652 |
| 19 | +commit 50f577451448a407ee8e78ed62aa09d209c91652 (github/master, master) |
| 20 | +Merge: f79a45d 87c248f |
| 21 | +Author: Michael Haggerty <[email protected]> |
| 22 | +Date: Mon Jul 11 07:55:19 2016 +0200 |
| 23 | + |
| 24 | + Merge pull request #9 from mhagger/recursive-option |
| 25 | + |
| 26 | + Add a `--recursive`/`-r` option |
9 | 27 | ```
|
| 28 | + |
| 29 | +There are many more options; see below. |
| 30 | + |
| 31 | + |
| 32 | +## Installation |
| 33 | + |
| 34 | +* Clone the repo somewhere on your system. |
| 35 | +* Ensure that `<somewhere>/bin/git-when-merged` is executable. |
| 36 | +* Put the contents of `<somewhere>/bin` on your `$PATH`. |
| 37 | + |
| 38 | +That's it! |
| 39 | + |
| 40 | +Or, using Homebrew: |
| 41 | + |
| 42 | +```ShellSession |
10 | 43 | $ brew update
|
11 | 44 | $ brew install git-when-merged
|
12 | 45 | ```
|
13 | 46 |
|
14 |
| -Usage |
15 |
| ------ |
16 |
| -git when-merged [OPTIONS] COMMIT [BRANCH...] |
17 | 47 |
|
18 |
| -Find the merge commit that brought COMMIT into the specified |
19 |
| -BRANCH(es). Specifically, look for the oldest commit on the |
20 |
| -first-parent history of each BRANCH that contains the COMMIT as an |
21 |
| -ancestor. |
| 48 | +## Usage |
| 49 | + |
| 50 | + git when-merged [OPTIONS] COMMIT [BRANCH...] |
22 | 51 |
|
| 52 | +Find 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. |
| 53 | + |
| 54 | +``` |
23 | 55 | Options:
|
24 | 56 | -h, --help show this help message and exit
|
25 | 57 | -p PATTERN, --pattern=PATTERN
|
@@ -88,6 +120,7 @@ Configuration:
|
88 | 120 | abbreviated to this number of characters (or longer if needed to
|
89 | 121 | avoid ambiguity). This value can be overridden using --abbrev=N
|
90 | 122 | or --no-abbrev.
|
| 123 | +``` |
| 124 | + |
| 125 | +`git when-merged` is originally based on [the suggestion here](http://stackoverflow.com/questions/8475448/find-merge-commit-which-include-a-specific-commit). |
91 | 126 |
|
92 |
| -Based on: |
93 |
| - http://stackoverflow.com/questions/8475448/find-merge-commit-which-include-a-specific-commit |
|
0 commit comments