如何在 Git 中跟踪子模块的配置文件? [英] How to track config files of submodules in Git?

查看:30
本文介绍了如何在 Git 中跟踪子模块的配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Git 中,我如何组织工作以跟踪库(即 git 子模块)的本地配置文件?

In Git, how can I organize work to track local config files of a library, which is a git submodule?

详情:

该库具有被跟踪的普通文件,以及位于其文件夹中但未被跟踪的默认配置文件,以避免重置或覆盖它们(它们列在 .gitignore 中).所有文件都在 lib 的文件夹或子文件夹中.

the library has normal files that are tracked, and default config files that are in it's folder, but not tracked, in order to avoid resetting or overwriting them (they're listed in .gitignore). All the files are in lib's folder or subfolders.

我也开始在 Git 中跟踪使用此库的项目之一.现在有一个困境:

I started tracking one of the projects, that use this lib, in Git too. Now there's a dilemma:

  • 如果我将这个项目中的 lib 设为子模块,我将无法跟踪配置文件(Git 会忽略它们,因为它们位于子模块文件夹中).

  • if I make the lib in this project a submodule, I won't be able to track the config files (Git will ignore them, since they're in the submodule folder).

按照我的理解,将所有事情都作为一个大项目进行跟踪是一个坏主意.

tracking everything as a big project is a bad idea, as I understand.

如果我do跟踪库中的配置文件,如何避免将它们重置为默认值?我是否在工作项目中创建一个分支并每次从 master 中拉取?那么,如果我编辑库和其中的配置文件怎么办?这一定会导致合并冲突,不是吗?

if I do track config files in the library, how can I avoid resetting them to default values? Do I make a branch in the working project and pull from master every time? Then, what if I edit the library and a config file in it? This must cause a merge conflict, doesn't it?

我想这并不新鲜,但我找不到任何建议.我会很感激从你们的经验中学习.

I guess this is not new, but I couldn't find any advice. I'll appreciate learning from your experience guys.

推荐答案

在主项目目录中跟踪您的配置文件并将符号链接放入库子目录中?

track your config file in main project directory and put a symlink into library subdirectory?

git add lib.conf
ln -s ../lib.conf lib/

还是我错过了什么?

这篇关于如何在 Git 中跟踪子模块的配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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