Reputation: 12176
This is a problem caused entirely by my own laziness. In some projects I tend to accumulate a bunch of temporary files that I don't want to delete yet, but don't want to commit either. And because they are just my local temp files, I don't want to .gitignore
them either.
Is there a way to make git status
only show untracked files if they have been modified in last X days?
Upvotes: 0
Views: 218
Reputation: 12176
Here is the script I use now instead of git status
:
#!/bin/bash
OLD_THRESHOLD="+30" # More than 30 days old
OLD_UNTRACKED=$(git status --porcelain=2 | \
grep '^[?] ' | cut -d' ' -f 2- | \
xargs -I X find X -maxdepth 0 -mtime $OLD_THRESHOLD )
git -c color.status=always status | grep -vF "$OLD_UNTRACKED"
It takes a list of the untracked files, and filters out any that have mtime
older than 30 days.
Note that the untracked files will still cause you (me?) trouble in e.g. git add folder
. It is still better to organize directories so that temporary files are in an gitignored folder.
Upvotes: 1