--
まず git fetch
でリモート追跡ブランチを作る。
git fetch <リモート名> <ブランチ名>
そして git checkout -t
でブランチを作ってその作ったブランチに切り替える。
git checkout -t <リモート追跡ブランチ>
もし別な名前でブランチを作りたい場合(developブランチからfeatureブランチを作るなど)は -b
オプションを付けてチェックアウトする。
git checkout -b <新しいブランチ名> <リモート追跡ブランチ>
例:git lg
は git log --graph …
のエイリアス。
y_ito@note MINGW64 /c/work/local_dev (master)
$ git branch
y_ito@note MINGW64 /c/work/local_dev (master)
$ git fetch origin develop
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From file:///c/work/pub_rep/uchinaaguchi
* branch develop -> FETCH_HEAD
* [new branch] develop -> origin/develop
y_ito@note MINGW64 /c/work/local_dev (master)
$ git branch
y_ito@note MINGW64 /c/work/local_dev (master)
$ git branch -r
origin/develop
y_ito@note MINGW64 /c/work/local_dev (master)
$ git checkout -t origin/develop
Switched to a new branch 'develop'
Branch 'develop' set up to track remote branch 'develop' from 'origin'.
y_ito@note MINGW64 /c/work/local_dev (develop)
$ git branch
* develop
y_ito@note MINGW64 /c/work/local_dev (develop)
$ git branch -r
origin/develop
y_ito@note MINGW64 /c/work/local_dev (develop)
$ git lg
* f6c90fa (HEAD -> develop, origin/develop) 2021-02-09 y_ito add develop
* 7194866 2021-02-09 y_ito first commit
y_ito@note MINGW64 /c/work/local_dev (develop)
$ git checkout -b feature origin/develop
Switched to a new branch 'feature'
Branch 'feature' set up to track remote branch 'develop' from 'origin'.
y_ito@note MINGW64 /c/work/local_dev (feature)
$ git branch
develop
* feature
y_ito@note MINGW64 /c/work/local_dev (feature)
$ git branch -r
origin/develop
y_ito@note MINGW64 /c/work/local_dev (feature)
$ git lg
* f6c90fa (HEAD -> feature, origin/develop, develop) 2021-02-09 y_ito add develop
* 7194866 2021-02-09 y_ito first commit