1

アップストリームのリポジトリは github にあり、たとえば「droid」でした。私はそれをフォークし、フォークにいくつかのコミットを追加しました。しかし、上流のリポジトリ「droid」は、「allRepo」などの別の既存のリポジトリのサブフォルダーに移動され、現在は「allRepo/droid」にあります。私もそれをフォークしました。コミットを my_fork_1 から my_fork_2 (またはローカル) に移動して、「allRepo」のフォークである my_fork_2 で作業を続けることはできますか?

4

2 に答える 2

3

Making some formerly separate project (with it's own separate repository and separate history) a part of some larger project at some subdirectory (subtree) is a subtree merge, and is described e.g. in "How to use the subtree merge strategy" HOWTO in git documentation, "Git Tools - Subtree Merging" chapter in "Pro Git" book (CC-NC-SA 3.0 license), and "Working with subtree merge" GitHub Help page (in Advanced Git section).

Note that you need to set up subtree merge only once; all future merging from subproject repo to whole project repo would get applied automatically. Or you can switch to using whole project repo after merging your commits into it.

There is also git subtree command, available in contrib area since git 1.7.11

于 2013-05-07T12:20:28.680 に答える
2

1つの解決策は、最初のgitから2番目のgitへの差分を適用しないことです

最初のリポジトリで:

git diff <hash> <hash>~1 > patch

2番目に:

git apply /some/path/to/the/patch
git commit

次のコマンドを使用して、最初のレポのメッセージを取得します。

git log <hash> -n 1 | tail -n+5 | sed -e "s/^ *//"
于 2013-05-07T09:20:01.937 に答える