gitignore 通配符不适用于多个文件扩展名
gitignore wildcard not working with multiple file extensions
可能重复了,但我找不到答案。
所以我有一个 .gitignore
文件:
transactions.csv
transactions_test.csv
**/test.gnucash*
test
**/test.gnucash.2*
以及以下目录:
LICENSE test.gnucash transactions_test.csv
main.py test.gnucash.20180615182021.gnucash transactions_testPUBLIC.csv
README.md test.gnucash.20180618121545.gnucash translations.json
test/ transactions.csv
但是当我 运行 git ls-tree -r master --name-only
我得到:
.gitignore
.vscode/settings.json
LICENSE
README.md
main.py
test.gnucash.20180615182021.gnucash
test.gnucash.20180618121545.gnucash
transactions_testPUBLIC.csv
translations.json
甚至比这更奇怪,如果我通过 glob tester 运行 它可以正常工作。 (见超链接)
对正在发生的事情有什么想法吗?我 运行宁 Git Windows Windows 10.
$ git --version
git version 2.17.0.windows.1
您已经将这些文件添加到 git,是吗? .gitignore
不影响 git 已知的文件;它仅将未跟踪的文件排除在添加考虑之外。
因此,如果您不想看到某个文件,您首先需要将其从 git rm --cached [FILE TO BE REMOVED]
(其中 --cached
will prevent git from actually deleting files)的跟踪中删除。正如@Bo-G 所指出的,这不会从存储库的历史记录中完全删除文件;它仍将是早期修订版或其他分支的一部分。
旧 post 但重要的是,即使您使用 git rm --cached [FILE TO BE REMOVED]
它仍然会存在 github 上的提交历史记录,如果您错误地发布了秘密
可能重复了,但我找不到答案。
所以我有一个 .gitignore
文件:
transactions.csv
transactions_test.csv
**/test.gnucash*
test
**/test.gnucash.2*
以及以下目录:
LICENSE test.gnucash transactions_test.csv
main.py test.gnucash.20180615182021.gnucash transactions_testPUBLIC.csv
README.md test.gnucash.20180618121545.gnucash translations.json
test/ transactions.csv
但是当我 运行 git ls-tree -r master --name-only
我得到:
.gitignore
.vscode/settings.json
LICENSE
README.md
main.py
test.gnucash.20180615182021.gnucash
test.gnucash.20180618121545.gnucash
transactions_testPUBLIC.csv
translations.json
甚至比这更奇怪,如果我通过 glob tester 运行 它可以正常工作。 (见超链接)
对正在发生的事情有什么想法吗?我 运行宁 Git Windows Windows 10.
$ git --version
git version 2.17.0.windows.1
您已经将这些文件添加到 git,是吗? .gitignore
不影响 git 已知的文件;它仅将未跟踪的文件排除在添加考虑之外。
因此,如果您不想看到某个文件,您首先需要将其从 git rm --cached [FILE TO BE REMOVED]
(其中 --cached
will prevent git from actually deleting files)的跟踪中删除。正如@Bo-G 所指出的,这不会从存储库的历史记录中完全删除文件;它仍将是早期修订版或其他分支的一部分。
旧 post 但重要的是,即使您使用 git rm --cached [FILE TO BE REMOVED]
它仍然会存在 github 上的提交历史记录,如果您错误地发布了秘密