git - gitignore 仅跟踪 2 个目录及其内容
问题描述
我想将我的 .gitignore 文件设置为仅跟踪 2 个目录以及其中的所有文件(有一些例外,如供应商)。我们为 cPanel 主机做了很多开发,发现用户目录中的所有其他 cPanel 目录也很难添加到本地 repo。
我们有 2 个目录要跟踪 public_html synergy
并想排除:synergy/vendor (composer) 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/*
解决方案
用于/**
选择所有子目录
*
!.gitignore
!a
!b
!a/**
!b/**
推荐阅读
- time-complexity - 递归的时间复杂度
- python - Python模块没有属性而属性存在
- html - Flexbox 根据内容(问题)自动确定容器的大小(宽度)
- php - 检查变量中是否存在子字符串
- pyspark - 以编程方式定义 SQL 列的大小
- vuejs2 - 使用 VueJS 访问和使用 Firestore 子集合数据(菜鸟问题)
- qt - 使用 QGraphicsView 时,是否有一种“简单的方法”可以将自定义 UI 添加到 Qt 应用程序?
- java - JavaFX 应用程序设计
- rest - 有没有可以像 Telnet 一样使用的 REST api
- oracle - Oracle - 将行转换为列