2016-05-10 6 views
0
repository A (already existing) 
examples\ 

repository B (already existing) 
code\ 
test\ 

に2本の枝のような2つのレポ取引の取り扱い - レポAが、レポBがどのように見えるべきであるとレポBの一部である必要があります -次の操作を実行しようとすると、Gitの

repository B 
code\ 
test\ 
examples\ 

我々がしたいです2つのリポジトリを分けてください。 ユーザーはそれらを個別にコミットできるはずです。 必要に応じて、repo Aをrepo Bにマージすることができます。 私はサブモジュールを考えることができましたが、これを行うための別の方法があります。 リポジトリB内のRepo Aを複製し、2つのリポジトリを保持して、同じリモートにプッシュすることはできますか。ブランチ名はリポジトリとして使用しますか?

答えて

2

いいえ、これに近いのはサブモジュールだけです。サブモジュールは別のディレクトリが必要です。ディレクトリには.gitディレクトリ(リポジトリ)が1つしかなく、repoAまたはrepoBのいずれかが含まれています。

0

.gitがgitサブツリーである(サブモジュールよりも)方が簡単ですが、これには別のディレクトリも必要です。プロンプトでgit subtreeを入力レポBに

git remote add repoA url.for.A 
git subtree add --prefix=examples/ repoA master 

作業

は素敵な使用方法の概要を示します。

マージ、プッシュ、プッシュがすべて可能です。厳密には必要ではありませんが、ベスト・プラクティスはであり、サブツリーとメインの間にコミット・スプリットを保持します(コミット・ログが有効であるように、パスexamples/とコミットを混在させないでください)。 git subtreeからの助けを引用する

[TIP] 
In order to keep your commit messages clean, we recommend that 
people split their commits between the subtrees and the main 
project as much as possible. That is, if you make a change that 
affects both the library and the main application, commit it in 
two pieces. That way, when you split the library commits out 
later, their descriptions will still make sense. But if this 
isn't important to you, it's not *necessary*. git subtree will 
simply leave out the non-library-related parts of the commit 
when it splits it out into the subproject later. 
+0

ありがとうございます。これは私のために働くかもしれないように見える。先に進む前に、コミットのパスを分けておくことについて詳しく説明してください。私は完全にそれを取得しません。ありがとう! – user3786914

+0

ありがとうございます。それは、必要以上に推奨されるものです。明確化し、参照を追加 – jaimedash

0

ます。また、リポジトリを分割し、それらが正しい場所後のダウンロードに移動している保つためにgit-repo toolに見ることができます。マニフェスト形式は​​です。

関連する問題