Git command to show which specific files are ignored by .gitignore

后端 未结 9 1080
我在风中等你
我在风中等你 2020-11-22 05:07

I am getting my feet wet with Git and have the following issue:

My project source tree:

/
|
+--src/
+----refs/
+----...
|
+--vendor/
+----...
         


        
9条回答
  •  囚心锁ツ
    2020-11-22 05:54

    (extending the other answers)

    Note, git check-ignore uses the committed .gitignore and not the one in your working tree! To play with it without polluting your git history, you might freely try to edit it, and then commit with a git commit --amend.

    This problem happens mainly if you need a workaround of the problem, that git doesn't follow directories. Enter in the .gitignore:

    dirtokeep/**
    !dirtokeep/.keep
    

    .keep should be a zero-length file in dirtokeep.

    The result will be that everything in dirtokeep will be ignored, except dirtokeep/.keep, which will result that also the dirtokeep directory will be constructed on clone/checkout.

提交回复
热议问题