Adam Nelson
Adam Nelson

Reputation: 8090

Git show files unchanged for a period of time

I'm looking at a new repository and want to see which files are 'dead'.

One step is to find all the files in the repository that have NOT been modified in the past 6 months.

I've tried various versions of git log but can't figure out how to show the list of files that are unchanged.

Upvotes: 3

Views: 47

Answers (2)

Holloway
Holloway

Reputation: 7367

It's not pretty and I'm sure there's a more straight forward way but this will give you a list of files in descending order of modification date.

git ls-tree -r --name-only HEAD | while read filename; do   echo "$(git log -1 --format="%ai" -- $filename) $filename" >> /tmp/modDates; done
sort -rn /tmp/modDates

Upvotes: 1

Andrew_Lvov
Andrew_Lvov

Reputation: 4668

Create a shell script with:

git ls-tree -r --name-only HEAD | while read filename; do
  echo "$(git log -1 --format="%ad" -- $filename) $filename"
done

run script redirecting output to file. Parse the file using regex, extract dates, compare to now-6 months.

Upvotes: 1

Related Questions