มีวิธีใดบ้างที่จะดูว่าเหตุใดบางไฟล์จึงถูกละเว้นโดย git (เช่นกฎใดใน.gitignoreไฟล์ที่ทำให้ไฟล์นั้นถูกละเว้น)?
ลองนึกภาพฉันมีนี้ (หรือสถานการณ์ที่ซับซ้อนมากขึ้นด้วยหลายร้อยโฟลเดอร์และหลายสิบ.gitignoreไฟล์:
/
-.gitignore
-folder/
    -.gitignore
    -subfolder/
              -.gitignore
              -file.txt
หากฉันใช้git add folder/subfolder/file.txtคอมไพล์อาจบ่นว่ามันถูกละเว้น:
The following paths are ignored by one of your .gitignore files:
folder/subfolder/file.txt
Use -f if you really want to add them.
มีวิธีใดบ้างที่จะรู้ว่าสิ่งใดที่เป็นไป.gitignoreได้ทั้งหมดที่มีกฎในการเพิกเฉยต่อไฟล์นี้และแสดงกฎด้วย? ชอบ:
The following paths are ignored by your folder/.gitignore file (line 12: *.txt)
folder/subfolder/file.txt
Use -f if you really want to add them.
หรือเพียงแค่:
$ git why-is-ignored folder/subfolder/file.txt
folder/.gitignore:12:*.txt
          GIT_TRACE_EXCLUDE=1 git statusอีกไม่นานจะเป็นวิธีเพิ่มเติมในการแก้ปัญหา.gitignoreกฎ ดูคำตอบที่แก้ไขของฉันด้านล่าง
                
git check-ignoreจะเร็ว ๆ นี้ (git1.8.5 / 1.9) จะมี--no-indexตัวเลือก ดูคำตอบของฉันด้านล่าง