Reputation: 8149
If I clone bootstrap: git clone https://github.com/twbs/bootstrap
And then do a git blame: git blame js/src/alert.js
It looks like every line was last touched by the same guy:
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 1) import Util from './util'
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 2)
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 3)
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 4) /**
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 5) * --------------------------------------------------------------------------
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 6) * Bootstrap (v4.0.0-alpha.6): alert.js
^7ffb61a (Patrick H. Lauke 2017-04-17 00:04:49 +0100 7) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
...
But if I look at the blame view on GitHub I see a bunch of different people: https://github.com/twbs/bootstrap/blame/v4-dev/js/src/alert.js
What's with the discrepancy? Am I using git blame wrong?
Upvotes: 4
Views: 1510
Reputation: 1324258
Another reason a git blame
can differ from the GitHub blame view is the ability to ignore/exclude commits while doing the blame.
git blame --ignore-rev
is available since Git 2.23 (Q3 2019)Ignore commits in the blame view (Beta)
It's now possible to ignore revisions in the blame view using a
.git-blame-ignore-revs
file in the root of your repository.For more information, see "Ignore commits in the blame view".
Screenshot of a banner on the blame view linking to the
.git-blame-ignore-revs
file
Upvotes: 1
Reputation: 933
Just run git fetch --unshallow
to have a full version of repo and this will fix the issue.
Here is a connected answer from another question https://stackoverflow.com/a/17937889/1758824
Upvotes: 6
Reputation: 8149
If you do a clone with limited depth, and the last change happened prior to the earliest revision pulled, git blame
will show incorrect results (I assume it's showing the person who did the earliest known commit).
Upvotes: 8