4

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?

1
  • 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. Commented Apr 17, 2017 at 4:08

3 Answers 3

8

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

Sign up to request clarification or add additional context in comments.

Comments

6

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

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.