3
2

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】リモートレポジトリをクローン後、ローカルにリモートブランチを作成する方法

Last updated at Posted at 2018-12-12

「everydayrails-rspec-2017」でRspecを勉強する前に
gitで躓いたのでメモします。

参考資料

リモートリポジトリからクローンする

$ git clone https://github.com/everydayrails/everydayrails-rspec-2017.git

ディレクトリ遷移

$ cd everydayrails-rspec-2017

ローカルとリモートのブランチを確認

$ git branch -a

すると、以下のような結果が表示されるはずです。

* master
remotes/origin/01-untested
remotes/origin/02-setup
remotes/origin/03-models
remotes/origin/04-factories
remotes/origin/05-controllers
remotes/origin/06-features
remotes/origin/07-requests
remotes/origin/08-dry-specs
remotes/origin/09-test-faster
remotes/origin/10-testing-the-rest
remotes/origin/11-tdd
remotes/origin/HEAD -> origin/master
remotes/origin/appendix-a-system-tests
remotes/origin/cucumber
remotes/origin/fix-geocoder-vcr
remotes/origin/master
remotes/origin/system-tests
remotes/origin/travis-ci

originの確認

$ git remote -v

origin https://github.com/everydayrails/everydayrails-rspec-2017.git (fetch)
origin https://github.com/everydayrails/everydayrails-rspec-2017.git (push)

リモートブランチをローカルに作成

$ git checkout -b my-01-untested origin/01-untested

my-01-untested
=> ローカルに作成するブランチの名前

origin/01-untested
=> リモートに存在するブランチ

ローカルにブランチが作成されていることを確認

$ git branch

master
* my-01-untested

ちゃんとローカルに作成されていますね!

3
2
0

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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?