使用Git跟踪本地忽略的文件 [英] Track local ignored files with Git
问题描述
在我们的仓库中,一些文件和文件夹被忽略。这里感兴趣的是:
- 建立输出文件夹,其中包含一些配置文件和外部二进制模块。请注意,这意味着这些感兴趣的文件位于已被忽略的文件夹(bin文件夹)中。
- 沿着源代码放置的安装脚本。这些脚本被忽略,因为它们是程序员特定的(例如它们包含到本地机器上的外部库的路径)。 然而,我会喜欢仅为自己追踪这些文件。主要是清洁后重新创建它们,但也有其他原因。
- Build output folders which contain (among others) some configuration files and external binary modules. Note that this means that those files of interest are located within already ignored folders ("bin" folders).
- Setup scripts which are placed along source code. Those scripts are ignored because they are programmer-specific (for example they contain paths to external libraries on local machine).
- My ignored-to-be-tracked files are not placed in a single folder (and it would be impractical to place them so). They are in various places in entire tree. And they are quite sparse by the way. Only a few of them.
- Alternative branch cannot be used since I need those files all the time in various branches, not just after switching to that alternative branch.
- template files (versioned)
- value files (stored elsewhere, with the right value for each developer's environment)
如何实现这一目标?
已经有类似的问题:
In our repository some files and folders are ignored. Of interest here are:
Yet I would like to trace those files for myself only. Mostly to recreate them easly after cleaning but there are other reasons as well.
How to achieve that?
There is already a similar question: Track files in local Git repo but ignore in remote. But it is only similar and thus answers proposed there are not applicable here:
First, you can add an ignored file to the index and commit it.
You just need to to git add --force -- /path/to/file
.
Second, you can add the setup files themselves: they contain private data.
You may consider the template approach, based on a content filter driver which, on checkout, would generate those files (as private non-versioned files) based on:
See for instance "How to keep different content of one file in my local and github repository?"
这篇关于使用Git跟踪本地忽略的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!