小编Clo*_*ock的帖子

Git不会取消忽略目录

我只想在一个更大的项目中跟踪git中的某些目录,其中大多数目录将被排除,只有少数目录将被跟踪.所以,我想在我的.gitignore中使用not-operators或者排除文件,ja?

为什么会这样:

% 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)
Run Code Online (Sandbox Code Playgroud)

"not"语法适用于最高目录中的文件.

% touch baz          
% vim .gitignore
% cat .gitignore 
*
!iwantthesefiles/
!baz
% …
Run Code Online (Sandbox Code Playgroud)

git

13
推荐指数
3
解决办法
9473
查看次数

标签 统计

git ×1