2

How to list only the file names that changed between two commits?

$git diff 518be77..24a893b --name-only

Question> How can I get the list of file names that have been changed by a user(i.e. Tom)?

I tried the following but it doesn't work.

$git diff 518be77..24a893b --name-only --author=Tom

Also the following command can list all modified files by the user but I have to manually find those two commits.

$ git log --author=Tom --name-only --oneline

Thank you

q0987
  • 34,938
  • 69
  • 242
  • 387

2 Answers2

2
git log --author=Tom --format='' --name-only HEAD~5.. | sort -u

--format='' prevents any output from git log except for file names; git log lists changed files in all commits by the author and there're probably many duplicates; sort -u handles those duplicates.

phd
  • 82,685
  • 13
  • 120
  • 165
  • where do I input those two commits hashes? – q0987 Jul 11 '19 at 02:33
  • You can replace HEAD~5 with .. – idlethread Jul 11 '19 at 07:44
  • In the `git log` arguments. First debug by looking at commits (`git log --author=Tom ..`), then add the rest. – phd Jul 11 '19 at 10:21
  • I tried the following command `git log --author=Tom --format='' --name-only 518be77..24a893b |sort -u`. In my git result, I still see many submit comments such as 'commit 3881432f56d8ed24c8aa04937864c22be71747fe' or 'Date: Fri Jun 21 14:34:31 2019 -0500' etc. git version 1.8.3.1 – q0987 Jul 11 '19 at 13:35
  • 2
    I found the solution: `git log --author=Tom --oneline --pretty="format:" --name-only 518be77..24a893b | awk 'NF' | sort -u` – q0987 Jul 11 '19 at 13:43
-1

Something like this should work:

git diff --author="Name of user" HEAD~5 --numstat
idlethread
  • 1,111
  • 7
  • 16