Questions tagged [git-blame]

git-blame is a git command that shows what revision and author last modified each line of a file.

git-blame is a git command that shows what revision and author last modified each line of a file.

https://www.kernel.org/pub/software/scm/git/docs/git-blame.html

git annotate is almost an alias for git blame (the output format is slightly different).

115 questions
13
votes
1 answer

Why username of Annotate(blame) is not same to author of commit in IntelliJ IDEA?

when I use git annotate in IntelliJ IDEA, the username of author of some lines is not same to author name of this commit, like this pic: As you can see, fan.qp and Qp is not same, why so? When I use bash or SourceTree to run git blame, the two…
ricklee
  • 131
  • 1
  • 4
13
votes
3 answers

Find first existence of a line of code in Git

I am trying to trace a piece of code (just a single line) to it's commit. Using blame only points me to a commit where this line in question was moved as a part of an extract method style refactoring. What techniques can I use to get to the commit…
zadam
  • 2,416
  • 2
  • 23
  • 32
11
votes
3 answers

How to blame previous versions of a specific line of code in VS 2015?

I'm using Visual Studio 2015 with Git integration. What I'm trying to achieve is going back in the history of a specific line of code. I know there is Source Control > Annotate. But then I get only to see the latest change. Then, I can right-click…
Dejan
  • 9,150
  • 8
  • 69
  • 117
11
votes
3 answers

Git tracking block of code moved/removed in a file

I have an old commit md5hash on myfile.extension with SOME CHANGE in the commit body (not the commit title/metadata). How can I generate a list of commits with SOME CHANGE modified (not just present) in the commits leading up to HEAD from md5hash…
sjakubowski
  • 2,913
  • 28
  • 36
11
votes
3 answers

git blame of particular lines inside all files filtered with grep command

I know how to run gblame inside a file. I know how to grep a content inside all files in a directory. I'd like to see gblame of particular lines around that one that contains a content. Example: $ blame -R "content" ./ I see a list of files. I want…
sensorario
  • 20,262
  • 30
  • 97
  • 159
11
votes
1 answer

Vim Fugitive: Gblame reblame options

I've been using Fugitive's Gblame recently but don't quite understand what "reblame" does. Can someone describe a little more clearly what these options do: - reblame at commit ~ reblame at [count]th first grandparent P reblame at…
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
10
votes
2 answers

How to go back to the results of :Gblame after selecting a particular commit?

From the README of the fugitive plugin for vim: :Gblame brings up an interactive vertical split with git blame output. Press enter on a line to edit the commit where the line changed, or o to open it in a split. Is it possible to go back to…
planetp
  • 14,248
  • 20
  • 86
  • 160
9
votes
1 answer

Git blame ignoring specific commit

I use git blame command to see in which commit have been added some particular code line, but sometimes I bump into the same problem: someone has made some kind of code formatting, or has changed function interface and refreshed all client code.…
Malov Vladimir
  • 490
  • 4
  • 11
9
votes
2 answers

How to preserve git author line-by-line when using a code formatter?

We are sick of linting. So we want to use black in our project. Unfortunately, it changes almost every other line in our project which would make us loose most of our authorship information. We use annotate in pycharm or git blame a lot to figure…
pascalwhoop
  • 2,984
  • 3
  • 26
  • 40
9
votes
3 answers

Git revert deleted file and preserve file history

Suppose I have a file a.txt. One day, I deleted it, committed, and pushed. The next day, I wanted like to revert the last commit, bringing back a.txt. I tried using git revert, but when I did git blame, all lines are showing the revert commit hash.…
fushar
  • 388
  • 2
  • 12
8
votes
1 answer

git blame for files that don't exist in current branch

I have a file that exists in branch_A but does not exist in branch_B. I want to run > git checkout branch_B > git blame branch_A file However, git complains that I don't have the file locally - which is correct but ignores the fact that I want to…
user1200257
8
votes
1 answer

Git: Equivalent of `--full-history` for `git bisect` and `git blame`

I've been using Git heavily for about 7 years. A few days ago I found a behavior that surprised me. I found git log, git blame and git bisect to exhibit this weird behavior. A friend let me know about the --full-history flag to git log that solved…
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
7
votes
0 answers

How to continue blaming in git

If I run git blame on a file, it lists per line which commit, author modified a particular line. But how can I blame on top of this blame, i.e. I want to see who changed these lines prior to the information in git blame. How can I do this?
Dsp guy sam
  • 205
  • 1
  • 7
7
votes
1 answer

Improve IntelliJ annotate (git blame)

I'd like to improve the "annotate option" (right click on code line number colon -> annotate), which is similar to git blame (but integrated to IntelliJ). 1/ Is it possible ? (via plugin or raw modification of IntelliJ files ? something else ?) 2/…
Nino DELCEY
  • 652
  • 1
  • 9
  • 25
7
votes
3 answers

Programmatically do "Git blame -w" in C#

I need to programmatically get the last author of a specific line in the Git history with C#. I tried using libgit2sharp : var repo = new LibGit2Sharp.Repository(gitRepositoryPath); string relativePath = MakeRelativeSimple(filename); var blameHunks…
JYL
  • 8,228
  • 5
  • 39
  • 63