Gitリポジトリを別のリポジトリのブランチにマージする 質問する

Gitリポジトリを別のリポジトリのブランチにマージする 質問する

リポジトリFooとリポジトリBarがあります。BarをFooとマージしたいのですが、しかしと呼ばれる別のブランチにのみ存在しますbaz

git switch -c baz<= Bar リポジトリをここに配置します。

ベストアンサー1

マージすることはできませんリポジトリ支店. マージすることができます支店別のリポジトリから支店ローカルリポジトリ内。

と の 2 つのリポジトリがあり、other-repo を base-repo にマージすると仮定しbase-repoますother-repo

リポジトリに変更しますbase-repo:

$ cd base-repo

other-repoリポジトリをリモートとして追加し、フェッチします。

$ git remote add other-repo [email protected]:xxx/other-repo.git # or use a path like ../foo if you have it locally on your machine
$ git remote update

現在のブランチに基づいて、base-with-other新しいブランチを作成します。base-repo

$ git switch -c base-with-other # choose any branch name you want and put it after -c

ブランチを現在のブランチsomebranchにマージしますother-repo:

$ git merge --allow-unrelated-histories other-repo/somebranch

( --allow-unrelated-historiesgit バージョン 2.9 より前では必要ありません)

おすすめ記事