如果子回购忽略所有内容,如何不忽略父回购中的所有内容? [英] How to not ignore everything in the parent repo when the child repo ignores everything?
问题描述
我有一个回购,忽略除了几个文件以外的所有内容,并且 .gitignore
看起来像这样:
I have a repo that ignores everything except a few files and the .gitignore
looks like this:
# first ignore everything
*
# then whitelist what's needed
!*/
!.gitignore
!wordpress/wp-content/plugins/check-last-login/*
!wordpress/wp-content/plugins/wp-issuetracker/*
!mediawiki/extensions/single-signon/*
此存储库是一个子存储库。它位于另一个存储库中,即父级。孩子的资料库忽略了一切,除了几件事情之外,父母也是这样做的,但我不想这样做。
This repository is a child repository. It is inside of another repository, the parent. The child repository is ignoring everything except the few things just fine, but the parent is also doing the same, but I don't want it to.
看起来像父回购遵循子回购的 .gitignore
文件的忽略规则。我尝试了.gitignoring子仓库的 .gitignore
文件,但是在使父项跟踪所有文件时无效。
It seems like the parent repo follows the ignore rules of the child repo's .gitignore
file. I tried .gitignoring the .gitignore
file of the child repo but that didn't work in making the parent track all files.
我如何让父母不忽略孩子忽略的任何文件?
How can I make the parent not ignore any of the files that the child ignores?
推荐答案
好的,我可以通过执行 git init
在一个已经有跟踪内容的目录中,并且smoketests都可以工作。我当然并不期待这一点。 git显然是将现有树(repo对象)放入子模块中:
Okay, I can make git do this the obvious way, by doing git init
in a directory that already has tracked content, and the smoketests all work. I certainly wasn't expecting that. git's apparently following existing trees (the repo objects) into the submodule:
# in a throwaway clone of an existing project
git init src
cd src
mkdir -p .git/info
echo "*.junk" >.git/info/exclude
touch foo.junk; git add .; git commit -m-
git ls-files -s
cd ..
git add src
git ls-files -s src
我有平行的历史。这实际上至少有一定意义;它通常不关心未跟踪的文件,并且 git add
必须忽略 .git
在根树中。 git拒绝这么做的具体原因是什么?我不能想到一个。
and I've got parallel histories. That actually makes at least some sense; it usually doesn't care at all about files that aren't tracked, and git add
has to ignore .git
in the root tree. For what concrete reason should git refuse to do this? I can't think of one offhand.
我会稍微担心有人可能会相当随意地决定这个行为的错误,并让git开始检查 .git
s,但考虑它我认为硬编码忽略 - .git
- 甚至在子树中,而不是只有在根本上可能是有意的。如果您开始与其他回购协议合作而不仅仅是发布,可能会让您手动同步一些,但编写脚本似乎很简单,乍看之下,您显然会获得某些 值的设置。 < shrug>。
I'd be mildly worried that someone will perhaps rather arbitrarily decide this behavior's a bug and make git start checking for .git
s on the way down, but thinking about it I think hardcoding ignore-.git
-even-in-subtrees rather than only in the root might even be intentional. It might leave you with some handroll synchronization if you ever start collaborating with other repos rather than just publishing, but writing the scripts to do it seems straightforward at first glance, and you're plainly getting some value out of the setup. <shrug>.
正如你发现的那样,repo-local排除了 .git / info / exclude
。
As you've discovered, repo-local excludes go in .git/info/exclude
.
这篇关于如果子回购忽略所有内容,如何不忽略父回购中的所有内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!