レポのサブディレクトリをGithubの異なるレポとしてフォークする方法
物語
これまでのサブディレクトリをフォークしてGit/Githubリポジトリ全体をフォークしたい.よく、私は最近、リポジトリの一つのサブディレクトリをforkしなければなりませんでした.このポストでは、それがどのように行われるかをあなたに教えます.
注意: GithubのWebインターフェースを通してサブディレクトリをフォークすることはできません
方法
クローンレポ
git clone https://github.com/<someones-username>/<some-repo-you-want-to-fork>
cd some-repo-you-want-to-fork
フォルダのGitサブツリーコマンドを使用してブランチを作成する
git subtree split --prefix=./src -b dir-you-want-to-fork
git checkout dir-you-want-to-fork
新しいgithubレポを作成します
Githubに向かい、ディレクトリをforkしたい新しいリポジトリを作成します.
新しく作成したレポをリモートとして追加する
cd some-repo-you-want-to-fork
git remote set-url origin https://github.com/<username>/<new_repo>.git
サブツリーを新しいリポジトリにプッシュする
git fetch origin -pa
git push -u origin dir-you-want-to-fork
新しいリポジトリ内のすべてのリモートブランチを取得する
git clone https://github.com/<username>/<new_repo>.git
cd new_repo
git checkout --detach
git fetch origin '+refs/heads/*:refs/heads/*'
git checkout dir-you-want-to-fork
あなたは現在、“フォーク”のsrc
サブディレクトリ.
メイン/ devブランチにマージします(トラブルシューティング)
あなたが走るならばgit merge master
そして、致命的な履歴をマージすることを拒否します.ラン
git checkout dir-you-want-to-fork
git merge --allow-unrelated-histories master
# Fix conflicts and
git commit -a
git push origin dir-you-want-to-fork
リファレンス
クローンレポ
git clone https://github.com/<someones-username>/<some-repo-you-want-to-fork>
cd some-repo-you-want-to-fork
フォルダのGitサブツリーコマンドを使用してブランチを作成する
git subtree split --prefix=./src -b dir-you-want-to-fork
git checkout dir-you-want-to-fork
新しいgithubレポを作成します
Githubに向かい、ディレクトリをforkしたい新しいリポジトリを作成します.
新しく作成したレポをリモートとして追加する
cd some-repo-you-want-to-fork
git remote set-url origin https://github.com/<username>/<new_repo>.git
サブツリーを新しいリポジトリにプッシュする
git fetch origin -pa
git push -u origin dir-you-want-to-fork
新しいリポジトリ内のすべてのリモートブランチを取得する
git clone https://github.com/<username>/<new_repo>.git
cd new_repo
git checkout --detach
git fetch origin '+refs/heads/*:refs/heads/*'
git checkout dir-you-want-to-fork
あなたは現在、“フォーク”のsrc
サブディレクトリ.メイン/ devブランチにマージします(トラブルシューティング)
あなたが走るならば
git merge master
そして、致命的な履歴をマージすることを拒否します.ランgit checkout dir-you-want-to-fork
git merge --allow-unrelated-histories master
# Fix conflicts and
git commit -a
git push origin dir-you-want-to-fork
リファレンス
Reference
この問題について(レポのサブディレクトリをGithubの異なるレポとしてフォークする方法), 我々は、より多くの情報をここで見つけました https://dev.to/mmphego/how-to-fork-a-subdirectory-of-repo-as-a-different-repo-on-github-4ob4テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol