Reputation: 967
I am trying to see the commits in the history of a repository but just for files with an specific extension.
If this is the directory structure:
$ tree
.
├── a.txt
├── b
└── subdir
├── c.txt
└── d
And this is the full history:
$ git log --name-only --oneline
a166980 4
subdir/d
1a1eec6 3
subdir/c.txt
bc6a027 2
b
f8d4414 1
a.txt
If I want to see logs for file with .txt extension:
$ git log --oneline *.txt
f8d4414 1
It returns only the file that is in the current directory, not in subdirectories. I want to include all possible subdirectories inside the current directory.
I've also tried:
$ git log --oneline */*.txt
1a1eec6 3
And:
$ git log --oneline *.txt */*.txt
1a1eec6 3
f8d4414 1
That works for this case, but it is not practical for more generic cases.
And:
$ git log --oneline HEAD -- *.txt
f8d4414 1
Without success.
Upvotes: 32
Views: 11521
Reputation: 49714
Try:
git log --oneline -- '*.txt'
The --
is used to indicate only positional arguments will follow. And '*.txt'
searches all folders from the current directory on down.
Alternatively, you could limit the results by starting the search in a subdirectory, e.g. -- 'sub/*.txt'
.
Upvotes: 40