198
147

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitでremoteリポジトリから新規にbranchを持ってくる方法

Last updated at Posted at 2015-05-15

新規にbranchを切って、それをremoteのリポジトリにpushしたとします。
別のPCでremoteにある、新しいbranchをpullしてくる方法です。

まずはremoteの新規リポジトリをpullする用のbranchを作ります。

新規branch作成
git branch new_branch_name origin/new_branch_name

次に新規branchにcheckoutしてremoteのbranchをpullします。

pull
git checkout new_branch_name
git pull origin new_branch_name

以下のようなエラーが出る場合はリモートの確認

error
fatal: Cannot update paths and switch to branch 'new_branch_name' at the same time.
Did you intend to checkout 'origin/new_branch_name' which can not be resolved as commit?

リモートのブランチのリストを確認

リモートの確認
git branch -r

branch 表示されない場合は更新

更新する
git fetch --prune

これで、リモートからブランチを作成可能。

198
147
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
198
147

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?