'List all files touched by commits in git

How to list all the files that were "touched" somewhere between two commits? I am looking for a command similar to git diff COMMIT1..COMMIT2 --name-only but including the files that were modified and reverted later.

For example, let's say I have a repository with a series of commits (linear history): C0<-C1<-C2<-C3<-C4. The commit C1 introduced a new file F and then the commit C3 removed it from the repository. I am looking for a command that, given C0 and C4, would tell me that somewhere in between there was a file F. Even though there is no such file in C0 and in C4. Therefore git diff wouldn't mention file F at all.



Solution 1:[1]

git diff ref1 ref2 takes into account only given commits, yes, but git log will find the missing steps and list files for each one, which sort will aggregate :

git log --pretty="" --name-only COMMIT1..COMMIT2 | sort -u

Solution 2:[2]

try git log to find the missing steps maybe git log --pretty=format:"" --name-only commit1..commit2 | sort -u

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 aulia octaviani