簡體   English   中英

如何忽略除git中具有特定擴展名的文件以外的所有文件?

[英]How can I ignore all files except those with a certain extension in git?

我需要忽略所有文件,除了那些以.php.css.html.js結尾的.php

這就是我現在在.gitignore文件中的內容:

*
!.php
!/*.php
!*.php

它確實忽略了所有內容,但只允許根目錄中的.php文件,同時隱藏所有其余文件。

*
!*/
!*.php
!*.css
!*.html
!*.js

對於那些想要包含位於@jmborr和@Racso等子目錄中的文件擴展名的人

# .gitignore for excluding all but certain files in certain subdirs

*
!*.cfg
!/**/
!certain/subdir/i_want_to_include/*.cfg

當你排除所有內容('*')時,你必須列出白名單文件夾('/ ** /'),然后才能列出白名單文件。

發現於: https//stackoverflow.com/a/33983585/5388625

暫無
暫無

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

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