0

For a given line (or any given unit of text) in a file, can I find out which commit last changed/created it?

This will help me to identify who last changed/created it, based on the commit.

Visual Studio 2015 for C# seems to have such feature. I guess it uses git to do that. Also some commentator said that "I have a bit more trust in git showing correct commit\merge author than in Tom remembering what he did."

Thanks.

Community
  • 1
  • 1
Tim
  • 1
  • 141
  • 372
  • 590
  • 1
    Possible duplicate of [Git: discover which commits ever touched a range of lines](http://stackoverflow.com/questions/14142609/git-discover-which-commits-ever-touched-a-range-of-lines) – Trisibo Mar 30 '17 at 21:35

1 Answers1

1

git blame -L

# Here -L100,+10 means "only look at the lines 100 to 100+11":
git blame -L100,+10 -- git-web--browse.sh

-L <start>,<end>
-L :<funcname>

Annotate only the given line range.
May be specified multiple times. Overlapping ranges are allowed.

<start> and <end> are optional. -L <start> or -L <start>, spans from <start> to end of file.

-L ,<end> spans from start of file to <end>.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167