Git 브랜치 전환

1 개요[ | ]

Switch Branch
Git 브랜치 전환
Git 브랜치 이동
Git 브랜치 변경
기존 브랜치로 전환
Bash
Copy
git checkout 기존브랜치명
→ 브랜치가 없는 경우 오류
신규 브랜치 생성하고 전환
Bash
Copy
git checkout -b 신규브랜치명
→ 브랜치가 이미 있는 경우 오류

2 실습[ | ]

Console
Copy
user01@localhost:~$ git clone https://github.com/laravel/laravel.git
Cloning into 'laravel'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (36/36), done.
remote: Total 31022 (delta 16), reused 25 (delta 8), pack-reused 30975
Receiving objects: 100% (31022/31022), 9.67 MiB | 5.75 MiB/s, done.
Resolving deltas: 100% (18345/18345), done.
Console
Copy
user01@localhost:~$ cd laravel/
user01@localhost:~/laravel$ git branch -a
* master
  remotes/origin/3.0
  remotes/origin/5.0
  remotes/origin/5.1
  remotes/origin/5.2
  remotes/origin/5.3
  remotes/origin/5.4
  remotes/origin/5.5
  remotes/origin/5.6
  remotes/origin/5.7
  remotes/origin/5.8
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/master
Console
Copy
user01@localhost:~/laravel$ git checkout 4.0
error: pathspec '4.0' did not match any file(s) known to git.
→ 없는 브랜치(4.0)로는 전환할 수 없다
Console
Copy
user01@localhost:~/laravel$ git checkout 5.0
Branch '5.0' set up to track remote branch '5.0' from 'origin'.
Switched to a new branch '5.0'
Console
Copy
user01@localhost:~/laravel$ git branch -a
* 5.0
  master
  remotes/origin/3.0
  remotes/origin/5.0
  remotes/origin/5.1
  remotes/origin/5.2
  remotes/origin/5.3
  remotes/origin/5.4
  remotes/origin/5.5
  remotes/origin/5.6
  remotes/origin/5.7
  remotes/origin/5.8
  remotes/origin/HEAD -> origin/master
  remotes/origin/develop
  remotes/origin/master

3 같이 보기[ | ]