zukucode
主にWEB関連の情報を技術メモとして発信しています。

Git Masterの内容をブランチに反映させる

Gitで、Masterの最新のソースを現在作業をしているブランチ(branch)に反映する方法を紹介します。

作業途中(修正途中)のソースがあればコミット(commit)しておきます。

まずは以下のコマンドでmasterブランチに移動します。

$ git checkout master

次に、masterブランチの情報を最新にします。

$ git pull origin master

次に、元いた作業ブランチに移動します。

$ git checkout 作業ブランチ名

最後にmasterブランチの内容を取り込みます。

$ git merge origin master

まとめると以下の流れになります。

$ git checkout master
$ git pull origin master
$ git checkout 作業ブランチ名
$ git merge origin master

関連記事