2017-10-20 107 views
0

我有一個設置爲忽略除特定模式的所有文件,像這樣一個混帳回購目錄:例外子文件夾中的.gitignore

# ignore all files except for template config files 
!/ 

/* 
!exception_dir/ 
!.gitignore 
!init.sh 
!blah.template.json 

我加入,我想設置例外子目錄對於。像這樣:

# ignore all files except for template config files 
!/ 

/* 
!exception_dir/ 
!.gitignore 
!init.sh 
!blah.template.json 
!exception2_subdir/ 

正如所料,上述語法不會忽略'exception2_subdir'內的所有文件。但是,我只想將某些文件添加到exception2_subdir中的git中。我通過谷歌搜索找到以下語法:

# ignore all files except for template config files 
!/ 

/* 
!exception_dir/ 
!.gitignore 
!init.sh 
!blah.template.json 
!exception2_subdir/add_this_template_file_to_git_please 
!exception2_subdir/add_this_template_file_to_git_please2 

此語法似乎沒有工作。當我嘗試手動添加'exception2_subdir/add_this_template_file_to_git_please'時,出現錯誤消息,該路徑被我的.gitignore文件忽略。有小費嗎?

請注意,這不是我的架構,所以我改變結構的能力有限。

謝謝!

埃裏克

+0

的[排除的.gitignore文件夾,但包括具體的子文件夾(HTTPS可能重複: //stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – phd

回答

0

我需要明確地屏蔽該目錄,則忽略該項目錄,然後屏蔽特定文件:/

# ignore all files except for template config files 
!/ 

/* 
!exception_dir/ 
!.gitignore 


exception_dir/* 
!exception_dir/add_this_template_file_to_git_please 
!exception_dir/add_this_template_file_to_git_please2 
相關問題