现在检查哪些提交文件可以被.gitignore
Check which commited files can be .gitignore'd now
我可以检查哪些提交的文件现在可以被 .gitignore 了吗?例如,我在旧提交中提交了 a.tmp
,但现在我在 .gitignore
上创建了一个规则,如 *.tmp
,我想取消跟踪这些旧文件。我想知道这是哪些文件以及如何取消跟踪它。
您可以使用 git check-ignore --no-index
来做到这一点。这是一个小演示。
$ 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
如果你想做整个存储库,find . -type f | xargs git check-ignore
(我忘了如何让 find 跳过 .git 目录)。
我可以检查哪些提交的文件现在可以被 .gitignore 了吗?例如,我在旧提交中提交了 a.tmp
,但现在我在 .gitignore
上创建了一个规则,如 *.tmp
,我想取消跟踪这些旧文件。我想知道这是哪些文件以及如何取消跟踪它。
您可以使用 git check-ignore --no-index
来做到这一点。这是一个小演示。
$ 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
如果你想做整个存储库,find . -type f | xargs git check-ignore
(我忘了如何让 find 跳过 .git 目录)。