Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Find last edits from a specific user in a specific file

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?

like image 680
Alik Avatar asked Aug 05 '11 12:08

Alik


3 Answers

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

git log --author=your_teammate -- path/to/file
like image 190
knittl Avatar answered Sep 30 '22 13:09

knittl


Yes! you can use git blame

git blame <file>

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

like image 41
TheOneTeam Avatar answered Sep 30 '22 14:09

TheOneTeam


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"

like image 23
Andy Avatar answered Sep 30 '22 14:09

Andy