我想在一个大项目中仅跟踪特定目录,其中大部分目录将被排除,只有少数目录将被跟踪。因此,我想在我的.gitignore或排除文件中使用not运算符,对吗?
为什么会发生这种情况:
为什么会发生这种情况:
% mkdir wtfgit
% cd wtfgit
% git init
Initialized empty Git repository in /home/foobar/wtfgit/.git/
% mkdir iwantthesefiles
% touch iwantthesefiles/foo
% mkdir idontwantthesefiles
% touch idontwantthesefiles/bar
% vim .gitignore
% cat .gitignore
*
!iwantthesefiles/
% git add --all
% git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
"not"语法对于最高级目录中的文件正常工作。
% touch baz
% vim .gitignore
% cat .gitignore
*
!iwantthesefiles/
!baz
% git add --all
% git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: baz
#
我如何获取git已跟踪的文件baz和foo?(基本上,目录中的非样式通配符匹配根本不起作用!)
谢谢!
!scripts/
和!scripts/*
。 - user151841