3

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?

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
Jesse Aldridge
  • 7,991
  • 9
  • 48
  • 75
  • 1
    Ah, I think it's because the full clone was taking too long, and I forgot I cancelled and did `git clone https://github.com/twbs/bootstrap --depth 1` instead. – Jesse Aldridge Apr 17 '17 at 04:08

3 Answers3

7

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).

Jesse Aldridge
  • 7,991
  • 9
  • 48
  • 75
4

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

Kate Kasinskaya
  • 823
  • 10
  • 10
1

Another reason a git blame can differ from the GitHub blame view is the ability to ignore/exclude commits while doing the blame.

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".

https://docs.github.com/assets/cb-146929/images/help/repository/blame-ignore-revs-file.png -- Screenshot of a banner on the blame view linking to the .git-blame-ignore-revs file

Screenshot of a banner on the blame view linking to the .git-blame-ignore-revs file

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250