I'm trying to see which of all the files I've modified but not yet committed, were modified in the last say 2 hours.
git status
shows me the list of all the modified files, but I only want to see those modified recently.
I've found this question Git show files that were changed in the last 2 days but it seems to work for committed files only.
Can this be done?
Git does not store when a file was modified, only when it was committed. Instead, check the file's modification time on your filesystem using find
.
find . -not -mmin +120 -not -path './.git/*'
-not -mmin +120
looks for files which have NOT been changed at least 120 minutes ago. -not -path './.git/*'
ignores the .git
directory.
This will check all files in the directory. If you just want to check the ones Git knows about, filter the list from git ls-files -m
on their modification times using xargs and find
.
git ls-files -m | xargs -I file find file -not -mmin +120
Or with xargs
and bash .
git ls-files -m | xargs -I file bash -c '(( $(date +%s) - $(stat --printf='%Y' file) < 7200 )) && echo file'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.