3

I know that we can use the command git show --pretty="" --name-only 90e34953 to list all files from a specific commit.

Is it possible to execute git log and include all files from the commits to the output?

Maybe there is a script which runs through each commit and inserts it into the command above?

e.g. (pseudocode)

$out = "";
foreach($commit in $commits) {
    $out .= $commit
    $out .= "----------------------------------------"
    $out .= (git show --pretty="" --name-only $commit)
}
$out > logfile.txt

We try to find out which commit added a specific file.

Black
  • 18,150
  • 39
  • 158
  • 271

2 Answers2

4
git log --diff-filter=A -- file

--diff-filter=A filters those commit(s) that add the file.

Yogesh_D
  • 17,656
  • 10
  • 41
  • 55
phd
  • 82,685
  • 13
  • 120
  • 165
1

Another option to find out which commit added the file is:

git log --reverse -- <file>

The top most commit is the one that has added the file.

sergej
  • 17,147
  • 6
  • 52
  • 89