Partiye geç kaldığımı biliyorum, ama işte cevabım.
@Joakim'in dediği gibi, bir dosyayı yok saymak için aşağıdaki gibi bir şey kullanabilirsiniz.
# Ignore everything
*
# But not these files...
!.gitignore
!someFile.txt
ancak dosya iç içe dizinlerde ise, kuralları el ile yazmak biraz zordur.
Örneğin, isterseniz tüm dosyaları atlamak için gitproje değil a.txtde bulunduğu aDir/anotherDir/someOtherDir/aDir/bDir/cDir. Sonra .gitignoreböyle bir şey olacak
# Skip all files
*
# But not `aDir/anotherDir/someOtherDir/aDir/bDir/cDir/a.txt`
!aDir/
aDir/*
!aDir/anotherDir/
aDir/anotherDir/*
!aDir/anotherDir/someOtherDir/
aDir/anotherDir/someOtherDir/*
!aDir/anotherDir/someOtherDir/aDir/
aDir/anotherDir/someOtherDir/aDir/*
!aDir/anotherDir/someOtherDir/aDir/bDir/
aDir/anotherDir/someOtherDir/aDir/bDir/*
!aDir/anotherDir/someOtherDir/aDir/bDir/cDir/
aDir/anotherDir/someOtherDir/aDir/bDir/cDir/*
!aDir/anotherDir/someOtherDir/aDir/bDir/cDir/a.txt
Yukarıda verilen .gitignoredosya, dışındaki tüm dizin ve dosyaları atlayacaktır.!aDir/anotherDir/someOtherDir/aDir/bDir/cDir/a.txt
Belirttiğiniz gibi, bu kuralları tanımlamak zordur.
Bu engeli çözmek için, sizin için kuralları oluşturacak git-do-not-ignore adında basit bir konsol uygulaması oluşturdum. Projeyi detaylı talimatla github'da ağırladım .
Kullanım Örneği
java -jar git-do-not-ignore.jar "aDir/anotherDir/someOtherDir/aDir/bDir/cDir/a.txt"
Çıktı
!aDir/
aDir/*
!aDir/anotherDir/
aDir/anotherDir/*
!aDir/anotherDir/someOtherDir/
aDir/anotherDir/someOtherDir/*
!aDir/anotherDir/someOtherDir/aDir/
aDir/anotherDir/someOtherDir/aDir/*
!aDir/anotherDir/someOtherDir/aDir/bDir/
aDir/anotherDir/someOtherDir/aDir/bDir/*
!aDir/anotherDir/someOtherDir/aDir/bDir/cDir/
aDir/anotherDir/someOtherDir/aDir/bDir/cDir/*
!aDir/anotherDir/someOtherDir/aDir/bDir/cDir/a.txt
Burada basit bir web sürümü de var
Teşekkür ederim.