Skip to content

Commit ba3d251

Browse files
authored
Add Ignore commits in the blame view to blame docs (github#26017)
1 parent 38c5724 commit ba3d251

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
143 KB
Loading

content/repositories/working-with-files/using-files/viewing-a-file.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,39 @@ In a file or pull request, you can also use the {% octicon "kebab-horizontal" ar
4949
![Blame button](/assets/images/help/repository/blame-button.png)
5050
4. To see earlier revisions of a specific line, or reblame, click {% octicon "versions" aria-label="The prior blame icon" %} until you've found the changes you're interested in viewing.
5151
![Prior blame button](/assets/images/help/repository/prior-blame-button.png)
52+
53+
{% if blame-ignore-revs %}
54+
55+
## Ignore commits in the blame view
56+
{% note %}
57+
58+
**Note:** Ignoring commits in the blame view is currently in public beta and subject to change.
59+
60+
{% endnote %}
61+
62+
All revisions specified in the `.git-blame-ignore-revs` file, which must be in the root directory of your repository, are hidden from the blame view using Git's `git blame --ignore-revs-file` configuration setting. For more information, see [`git blame --ignore-revs-file`](https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-fileltfilegt) in the Git documentation.
63+
64+
1. In the root directory of your repository, create a file named `.git-blame-ignore-revs`.
65+
2. Add the commit hashes you want to exclude from the blame view to that file. We recommend the file to be structured as follows, including comments:
66+
67+
```ini
68+
# .git-blame-ignore-revs
69+
# Removed semi-colons from the entire codebase
70+
a8940f7fbddf7fad9d7d50014d4e8d46baf30592
71+
# Converted all JavaScript to TypeScript
72+
69d029cec8337c616552756310748c4a507bd75a
73+
```
74+
75+
3. Commit and push the changes.
76+
77+
Now when you visit the blame view, the listed revisions will not be included in the blame. You'll see an **Ignoring revisions in .git-blame-ignore-revs** banner indicating that some commits may be hidden:
78+
79+
![Screenshot of a banner on the blame view linking to the .git-blame-ignore-revs file](/assets/images/help/repository/blame-ignore-revs-file.png)
80+
81+
This can be useful when a few commits make extensive changes to your code. You can use the file when running `git blame` locally as well:
82+
83+
```shell
84+
git blame --ignore-revs-file .git-blame-ignore-revs
85+
```
86+
87+
{% endif %}

data/features/blame-ignore-revs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Reference: #6378.
2+
# Documentation for the `.git-blame-ignore-revs` file and the blame view
3+
versions:
4+
fpt: '*'
5+
ghec: '*'
6+
ghes: '>3.5'

0 commit comments

Comments
 (0)