Reputation: 139
I work locally under Windows. I have a local git repo and already included some files. The folder (and subfolders) where I am working in includes many other files that are not yet tracked and not known to git. Some of these files have not been changed for many months. I need to add some, but not all of these files. The criterium for inclusion should be the date of last change (e.g. I want to "git add" only files that have been modified within the last month).
Is there a way to do this? Searching help files and threads here only showed me solutions when the files are already tracked.
Upvotes: 1
Views: 103
Reputation: 3950
Not possible with git only, but if you have "git bash" or WSL available, you should be able to run something like
find . -type f -mtime -31 -not -path '*/.git/*' -exec git add -v -- {} +
to add files modified within the last 31 days.
Notes:
.
-exec
part:find . -type f -mtime -31 -not -path '*/.git/*'
git add
's --dry-run
option (short: -n
):find . -type f -mtime -31 -not -path '*/.git/*' -exec git add -v -n -- {} +
Edit history:
find
's -print
expression use git add
's -v
option (a.k.a. --verbose
). This way only the files that were actually added are listed, not all files that were passed to the git add
command.Upvotes: 2