2017-06-21 8 views
2

私はGitHubプロジェクトをフォークしました。私は、元のプロジェクトのマスターブランチのクローンである新しいブランチを作成したい(マスターブランチには、最後にフォークしたときの新しいコミットがある)。元のGitHubプロジェクトからブランチをフォークにどのようにクローンできますか?

どうすればいいですか?

+0

ためthe GitHub docsはたぶんあなたの支店で元にリモートレポを変更し、最新の変更 'Gitのpull'を引く?を参照してください。 4878249/how-do-i-change-the-git-branch-is-tracking#4879224 – Hackerman

答えて

0

まずはconfigure a remote for a the original repoが必要です。

$ git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git 
$ git fetch upstream 

これで元のrepoの任意のブランチで任意のgitコマンドを使用できます。

$ git checkout master 
$ git pull upstream master 

もちろん、master以外のブランチをチェックアウトすることもできます。

$ git checkout my-radical-new-feature 
$ git pull upstream master 

通常、ここに示すようにローカルのマスターブランチに直接プルし、ローカルのマスターを他のブランチにマージします。

$ git checkout master 
$ git pull upstream master 
$ git checkout my-radical-new-feature 
$ git merge master 

https://stackoverflow.com/questions/のような...詳細

0

上流から取得し、そのブランチにチェックアウトし、フォークのそのブランチに強制的にプッシュします。

git fetch upstream 
git checkout <target branch> 
git push -f origin <target branch> 

免責事項:これはテストしていません。

+0

これはOPにすでに 'upstream'リモートが設定されていることを前提としています。 –

関連する問題