6

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

In details:

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.

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

  • 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.

  • 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.

4

2 に答える 2

4

サブモジュールを使用する場合、サブモジュールの履歴に新しいリビジョンが作成されるため、コンテナー(ここではlibを使用するプロジェクト)のために変更を加えないようにする必要があります。

たとえば、libの場合、次のベースとなる構成テンプレートファイルを参照することができます。

  • デフォルト値の構成ファイルの生成(libにはアーカイブされたデフォルト値のファイルがあり、完全であるが追跡されていない構成ファイルを生成するために使用できます)
  • またはカスタム構成ファイルの生成(プロジェクトには独自の構成ファイル値があり、それを使用して、ライブラリ内の同じ場所に追跡されていない構成ファイルを生成します)

「トークン化された値を含む構成ファイルテンプレート、およびそのconfig.templateファイルをプライベート(および無視される)構成ファイルに変換するスクリプト」は、マージ管理に関するこのSOの質問で提案したアプローチです。

設定ファイルに関するその他のより一般的なアドバイスは、このSOの質問にあります。

于 2009-09-15T19:52:02.737 に答える
3

メイン プロジェクト ディレクトリで構成ファイルを追跡し、シンボリック リンクをライブラリ サブディレクトリに配置しますか?

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

または私は何かが恋しいですか?

于 2009-09-15T20:00:49.410 に答える