gitignore 无法从排除中排除文件夹。

huangapple go评论64阅读模式
英文:

gitignore cannot exclude folders from exclusion

问题

I have troubles excluding a pattern from .gitignore (I want the folder to be added)

currently my .gitignore is like:

/*
!file1.conf
!file2.ini
!*.xml
!confs/*

in a hierarchy that have really many files

When I git add . it correctly add xmls present in the root directory along with file1.conf and file2.ini but no file from confs/ folder is added.

git status returns:

file1.conf  
file2.ini
data1.xml
logback.xml

but the expected confs/filea.json is missing

英文:

I have troubles excluding a pattern from .gitignore (I want the folder to be added)

currently my .gitignore is like:

/*
!file1.conf
!file2.ini
!*.xml
!confs/*

in a hierarchy that have really many files

When I git add . it correctly add xmls present in the root directory along with file1.conf and file2.ini but no file from confs/ folder is added.

git status returns:

file1.conf  
file2.ini
data1.xml
logback.xml

but the expected confs/filea.json is missing

答案1

得分: 2

你应该包括文件夹 文件夹内容,所以你需要同时包括 confs/confs/*:

*
!file1.conf
!file2.ini
!*.xml
!confs/
!confs/*

gitignore 无法从排除中排除文件夹。
gitignore 无法从排除中排除文件夹。

英文:

You should include folder and folder contents, so you need both confs/ and confs/*:

*
!file1.conf
!file2.ini
!*.xml
!confs/
!confs/*

gitignore 无法从排除中排除文件夹。
gitignore 无法从排除中排除文件夹。

huangapple
  • 本文由 发表于 2023年6月29日 15:37:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/76578945.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定