samiaj
samiaj

Reputation: 449

How to retrieve the last modification date of all files with specific extension in Git?

I know how to retrieve the last modification date of a single file in a Git repository:

git log -1 --format="%ad" -- path/to/file

Is there any way we can list last modification date of files with specific extension, like I say all files with .config extension?

Upvotes: 3

Views: 568

Answers (1)

padawin
padawin

Reputation: 4476

First, what you want to get is the last commit date. A file can be modified (on the system) while not having been committed.

To get the last committed date of all the config files, you can do something like:

find . -name "*.config" -exec sh -c 'echo "{} - $(git log -n 1 --pretty="format:%ad" {})"' \;

You can look at man git-log for the pretty option for different formatting if you need.

Upvotes: 3

Related Questions