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.
Using git log --follow -p bar will show the file's entire history, including any changes to the file when it was known as foo .
Use git log --all <filename> to view the commits influencing <filename> in all branches.
To find out which files changed in a given commit, use the git log --raw command. It's the fastest and simplest way to get insight into which files a commit affects.
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'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With