gitignore仅跟踪其内容的2个目录

时间:2019-06-18 07:28:51

标签: git

我想设置我的.gitignore文件,使其仅跟踪2个目录以及其中的所有文件(某些例外,例如供应商)。我们对cPanel主机做了很多开发工作,发现用户目录中的所有其他cPanel目录都很难添加到本地存储库中。

我们有2个目录要跟踪 public_html 协同作用

并要排除: 协同/供应商(撰写者) synergy / logs / *(仅此目录中的文件,而非目录) public_html / uploads / *

我尝试了以下操作(从另一个stackoverflow问题中得到了它),但这似乎排除了所有子目录。

# Ignore everything
*

# But not these files...
!.gitignore
!synergy
!synergy/
!synergy/*
!public_html
!public_html/
!public_html/*

# Further specific excludes:
synergy/vendor
synergy/vendor/*
synergy/logs/*
/public_html/uploads/
/public_html/uploads/*

1 个答案:

答案 0 :(得分:1)

使用/**选择所有子目录

*
!.gitignore

!a
!b
!a/**
!b/**