git blame 忽略指定 commit

335 阅读1分钟
我正在参加掘金的年度,欢迎来给我投票打榜

场景

在一个没有 eslint、 prettier 的项目中,当你中途 format 了整个仓库之后, git blame 就会废掉,全是 format 的 commit。

解决方案

可以创建一个 .git-blame-ignore-revs 文件,写入要忽略的 commit id。

比如:

# Apply with:
# `git config --local blame.ignoreRevsFile .git-blame-ignore-revs`

# [Add Prettier and format files](https://github.com/withastro/starlight/pull/393)
9b172f5ee09697d80f301e9b70aca1946419ce24

执行命令:git config --local blame.ignoreRevsFile .git-blame-ignore-revs 就好了。

GitHub 也会自动读取 .git-blame-ignore-revs 文件。


如果你觉得内容对你有帮助,欢迎「转发」       「点赞」       「收藏」   

你的鼓励是我最大的支持,猛戳「关注」,后续文章更精彩。