Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

combine 'git status' and find command with mmin or mtime option

'git status' command gives the list of files changed since the last commit.

find command with mmin or mtime option gives the list of files saved within a given time length. But it would also include files I have edited and then undone the changes i.e. those whose contents have not been changed.

What I need is to get the list of files which have been modified (contents changed) within a given time length. Is it possible ?

Thanks

like image 291
air4x Avatar asked Jan 28 '26 19:01

air4x


1 Answers

What you want is Git whatchanged.

Here's an example using whatchanged to show added files (I didn't happen to have modified files in the test repo I used, but you can easily limit the results to modified files instead of added files):

$ git whatchanged --after='2012-07-07 17:20' --before='2012-07-28 23:31' --diff-filter=A -r --oneline --name-only
82b9dcf F
E/F
95a02ce D
D

As is noted in the manual, whatchanged uses rev-list and diff-tree behind the scenes and whatchanged also uses options available with rev-list and diff-tree. The diff-tree --diff-filter option will:

Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B).

If you want to use rev-list and diff-tree directly (to avoid the commit log whatchanged wants to output), you could use:

$ git diff-tree --diff-filter=A -r --name-only $(git rev-list -n 1 --before='2012-07-07 17:20' HEAD) $(git rev-list -n 1 --before='2012-07-28 23:31' HEAD)
D
E/F
like image 146
Dan Cruz Avatar answered Jan 30 '26 09:01

Dan Cruz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!