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
  • 15,426
  • 32
  • 140
  • 232

2 Answers2

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

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

Yogesh_D
  • 15,585
  • 9
  • 35
  • 50
phd
  • 69,888
  • 11
  • 97
  • 133
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
  • 15,727
  • 6
  • 44
  • 82