簡體   English   中英

gitignore 特定目錄的所有子目錄中除 .json 文件之外的所有文件

[英]gitignore all files except the .json files in all subdirectories of a particular directory

我當前的目錄樹看起來像:

.
├── test1
│   ├── test.docx
│   ├── test.jpg
│   ├── test.json
│   ├── test2
│   │   ├── test.docx
│   │   ├── test.jpg
│   │   ├── test.json
│   │   └── test4
│   │       ├── test.docx
│   │       ├── test.jpg
│   │       └── test.json
│   └── test3
│       ├── test.docx
│       ├── test.jpg
│       └── test.json
└── test5
    ├── test.docx
    ├── test.jpg
    ├── test.json
    ├── test2
    │   ├── test.docx
    │   ├── test.jpg
    │   ├── test.json
    │   └── test4
    │       ├── test.docx
    │       ├── test.jpg
    │       └── test.json
    └── test3
        ├── test.docx
        ├── test.jpg
        └── test.json

我想忽略除test1目錄下的.json文件之外的所有內容。

我的.gitignore文件如下所示:

/*
!/.gitignore
!/test1
/test1/**/*.json

我的git status -sb output 是:

## No commits yet on master
?? .gitignore

因此,它沒有跟蹤test1目錄下的.json文件。

這里的解決方案可能是什么?

您可以將以下行添加到您的.gitignore文件中:

# ignore all files
**/*.*

# except json files in test1 folder
!test1/**/*.json

還有一個不錯的帖子,您可以在其中找到解決方案的基礎知識。

僅嘗試在 .gitignore 文件中的這一行

test1/.*.json

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM