简体   繁体   English

当子存储库忽略所有内容时,如何不忽略父存储库中的所有内容?

[英]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.

相关问题 除了几个文件,我如何忽略我回购中的所有内容? - How do I ignore everything in my repo except a few files? 如何清除本地存储库中的所有内容并合并到新存储库中? - how do I make erase everything off of local repo and merge in new repo? 如果我推送一个克隆的 repo,它会拥有克隆 repo 的所有内容吗? - If I push a cloned repo, will it have everything that the cloned repo has? 尝试推送到全新的远程服务器时,全新的git repo会说“一切都是最新的” - Entirely new git repo says “Everything up-to-date” when trying to push to entirely new remote 如何将存储库合并到父目录存储库 - How to merge a repo into a parent directory repo Git推送到本地仓库说“一切都是最新的”,这不是 - Git push to local repo says “everything up to date”, it isn't Git:删除除某个目录以外的所有内容(BFG Repo Cleaner) - Git: Remove everything except for a certain directory (BFG Repo Cleaner) 推送后,git会说一切都是最新的,但是更改不在仓库中 - After push, git says everything up to date but changes are not in the repo 检查本地git repo是否已提交所有内容并推送到master - Check that the local git repo has everything committed and pushed to master 将“子”git repo 合并/移动到“父”git repo - Merging/moving “child” git repo into “parent” git repo
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM