.gitignore - 忽略文件的目录 [英] .gitignore - directory of ignore files

查看:422
本文介绍了.gitignore - 忽略文件的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以创建.gitignore文件夹而不是文件?这样,Git会解析.gitignore / ignorerulesA和.gitignore / ignorerulesB都作为忽略文件吗?



我可以看到这是有用的情况下,我有两个存储库我想合并的非重叠结构。

  repoa 
filea
foldera
。 gitignore / ignorea

repob
fileb
folderb
.gitignore / ignoreb

有了这个结构,我可以合并repoa和repob而不会产生任何冲突。

如果这已经不可行,是否有意义请求此功能?



我不确定我的问题的搜索结果是否如此糟糕,因为:


  1. 也许这只是一个坏主意

  2. 我没有正确的搜索词.gitignore文件夹只是一堆关于如何忽略文件夹的说明。 多个.gitignore文件只是谈论将.gitignores放在不同的文件夹中。

  3. 我是一个属,之前没有人想到这一点。






更新:澄清

如果我们在上面的示例中使用这两个存储库并为每个存储库应用不同的.gitignore规则。



例如,在repoa中,我想忽略foldera和repob I想要忽略fileb。我在这种情况下结束了

  repoa 
filea
foldera
.gitignore
foldera

repob
fileb
folderb
.gitignore
fileb

现在我要创建repoab。

  mkdir repoab 
cd repoab
git init
git remote add repoa / path / to / repoa
git remote add repob / path / to / repob
git pull repoa master
git pull repob master
rom ../repob
*分支大师 - > FETCH_HEAD
自动合并.gitignore
CONFLICT(添加/添加):在.gitignore中合并冲突
自动合并失败;修复冲突,然后提交结果。

基本上每次我处理repoa或repob的更新时,我都必须处理有了这个冲突,这当然是不理想的。

解决方案


有了这个结构,我可以合并repoa和repob没有任何冲突。


但是你不行。 .gitignore 文件可以有排除,即使没有这些文件,一个回购站可能会期望某些类型的文件被包含在其他期望它们生成的地方(并且忽略他们)。订单很重要。

您可以将 .gitignore s放入它们适用的树中, foldera / .gitignore 等等。这对顶层文件没有帮助,但是如果你的规格有冲突,那么你在那里也有冲突的文件,所以忽略混乱并不是真正的问题。


Is there any way to create a .gitignore folder rather than a file? Such that Git would parse .gitignore/ignorerulesA and .gitignore/ignorerulesB both as ignore files?

I could see this being useful in a scenario where I have two repositories with a non-overlapping structure that I want to merge.

repoa
  filea
  foldera
  .gitignore/ignorea

repob
  fileb
  folderb
  .gitignore/ignoreb

With this structure I can merge repoa and repob without any conflicts.

If this isn't possible already, would it make sense to request this feature?

I'm not sure if the search results for my question are so poor because:

  1. maybe this is just a bad idea
  2. I don't have the right search term ".gitignore folder" is just a bunch of instructions on how to ignore a folder. "multiple .gitignore files" just talks about placing .gitignores in different folders.
  3. I'm a genus and nobody has thought of this before.


Update: Clarification

If we take the two repositories in my example above and apply different .gitignore rules for each repository.

For instance in repoa I want to ignore foldera and in repob I want to ignore fileb. I end up in this situation

repoa
  filea
  foldera
  .gitignore
    foldera

repob
  fileb
  folderb
  .gitignore
    fileb

Now I want to create repoab.

mkdir repoab
cd repoab
git init
git remote add repoa /path/to/repoa
git remote add repob /path/to/repob
git pull repoa master
git pull repob master
rom ../repob
 * branch            master     -> FETCH_HEAD
Auto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignore
Automatic merge failed; fix conflicts and then commit the result.

Essentially every single time I deal with an update to repoa or repob I'm going to have to deal with this conflict, which is certainly not ideal.

解决方案

With this structure I can merge repoa and repob without any conflicts.

But you can't. .gitignore files can have exclusions, and even without those it's possible for one repo to expect some kinds of files to be included where the other expects them to be generated (and so ignores them). Order matters.

You can put your .gitignores in the trees they apply to, foldera/.gitignore and so forth. That won't help for toplevel files, but if you've got conflicting specs there you also have conflicting files there, so the ignore mess isn't really the problem there.

这篇关于.gitignore - 忽略文件的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆