5

I have a project which sources are controlled with help of git.

Right now I want to find out when my teammate made last edits in a specific file. I want to find out SHA1 of commit or to see his edits as diff.

I guess I can use git log --stat <path/to/file> and review list of all commits where my file was changed.

Are there any quick ways to do it?

Konstantin
  • 24,271
  • 5
  • 48
  • 65

3 Answers3

9

you can use git log with a pathspec and --author option:

git log --author=your_teammate -- path/to/file
knittl
  • 246,190
  • 53
  • 318
  • 364
  • Wow. I've forgot to review `git help log`. Thank you. `git log --author=your_teammate -- path/to/file -n 1` does the work :) – Konstantin Aug 05 '11 at 12:56
3

Yes! you can use git blame

git blame <file>

every line of that file will be shown who is the one edited the last.

TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
  • If you have a file is thousands of lines long, this is a horribly tedious way to figure out what the author wants – Andy Aug 05 '11 at 12:51
  • Actually `git blame` will not help me if edits of my teammate where overwritten in later commits by another author. – Konstantin Aug 05 '11 at 12:57
  • @Konstantin: it seems that your question is not asking what you describe in OP :p – TheOneTeam Aug 05 '11 at 12:59
2

I would use this line
git log --format="%H--%ad-%an" fileName

If you only want the last change, use this
git log --format="%H--%ad-%an" -n 1 fileName

If you are looking for a single specific author, pipe it through grep
git log --format="%H--%ad-%an" fileName | grep "Author Name"

Andy
  • 44,610
  • 13
  • 70
  • 69