Is possible I check which commited files can be .gitignore'd now? For instance, I commited a.tmp
in an old commit, but now I create a rule like *.tmp
on .gitignore
and I like to untrack this old files. I like to know which files are this and how I can untrack it.
Asked
Active
Viewed 28 times
0

David Rodrigues
- 12,041
- 16
- 62
- 90
-
Note: `GIT_TRACE_EXCLUDE=1 git status` will soon (git 2.8, March 2016) be an additional way to debug `.gitignore` rules. See http://stackoverflow.com/a/18953923/6309 – VonC Mar 01 '16 at 16:13
1 Answers
0
You can use git check-ignore --no-index
to do this. Here's a small demonstration.
$ git init foo
cd fInitialized empty Git repository in /Users/schwern/tmp/foo/.git/
$ cd foo
$ touch a.tmp
$ git add a.tmp
$ git ci -a
[master (root-commit) 30f7de9] Add a.tmp
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a.tmp
$ echo '*.tmp' > .gitignore
$ cat .gitignore
*.tmp
$ git check-ignore --no-index *
a.tmp
If you want to do the whole repository, find . -type f | xargs git check-ignore
(I forget how to make find skip the .git directory).

Schwern
- 153,029
- 25
- 195
- 336