Git忽略dir,但在目录

时间:2016-02-07 21:36:48

标签: git

是的,这是一个重复的问题。但到目前为止的答案对我不起作用。我在osX上运行git v 2.6.4。

这是我的.gitignore

/src/artwork/dist
/dist/*
!/dist/dandelion.yml

对于第2行,我还尝试了/dist/**,但正在运行git status仍未显示/dist/dandelion.yml

请注意,/dist也是一个git repo,如果必须,我想避免使用git add -f。对我来说强迫意味着你做错了什么。

1 个答案:

答案 0 :(得分:0)

为什么不向每个文件夹添加.gitignore以包含该文件。由于您有多个dist文件夹,因此您应该为每个文件夹添加.gitignore特定规则。

如果我理解你这是你的文件夹结构:

|
|-dist
.
.
|-src
   |- artwork
         |- dist 

到目前为止你做了什么:

# ignore the dist folder under src/artwork
/src/artwork/dist

# ignore dist folder under the root folder
/dist/*

# DO NOT ignore the dandelion.yml under the root/dist folder
!/dist/dandelion.yml
  

请注意/ dist也是一个git repo,

为什么不将它添加为子模块?这样可以节省您将所需文件添加到.gitignore&如果它是一个内心的回购,它会更有意义。

submodule

enter image description here