[英]How to not ignore everything in the parent repo when the child repo ignores everything?
I have a repo that ignores everything except a few files and the .gitignore
looks like this: 我有一个回购协议,它会忽略除了几个文件以外的所有内容, .gitignore
看起来像这样:
# 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. 子存储库会忽略一切,除了几件事就好了,但是父存储库也在做同样的事情,但是我不希望这样做。
It seems like the parent repo follows the ignore rules of the child repo's .gitignore
file. 看起来父级回购遵循子级回购的.gitignore
文件的忽略规则。 I tried .gitignoring the .gitignore
file of the child repo but that didn't work in making the parent track all files. 我试着.gitignoring子仓库的.gitignore
文件,但是在使父目录跟踪所有文件上没有用。
How can I make the parent not ignore any of the files that the child ignores? 如何使父项不忽略子项忽略的任何文件?
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. 好的,我可以通过在已经跟踪了内容的目录中执行git init
来使git做到这一点,而smoketests可以正常工作。 I certainly wasn't expecting that. 我当然没想到这一点。 git's apparently following existing trees (the repo objects) into the submodule: git显然将现有的树(回购对象)跟随到子模块中:
# 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
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. 它通常根本不关心未跟踪的文件,并且git add
必须忽略根树中的.git
。 For what concrete reason should git refuse to do this? git应该出于什么具体原因拒绝这样做? I can't think of one offhand. 我想不出一个副手。
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. 我会婉转担心有人也许会相当随意地决定这种行为是一个错误,使混帐开始检查.git
S ON一路走低,但关于它的思考,我认为硬编码ignore- .git
-甚至,在子树,而不是仅根源可能甚至是故意的。 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>. <耸肩>。
As you've discovered, repo-local excludes go in .git/info/exclude
. 如您所知,repo-local排除在.git/info/exclude
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.