코드숨 깃 강의 3강 merge 과제 회고

[코드숨] 깃 트레이닝 3강 Merge 과제 회고 🤔

깃 3주차 과제 터미널

  • 과제 인증

💡알게된 사실

git clone시에 브랜치까지 들고 오지 않는다. 원하는 upstream 브랜치로 이동하고자 한다면 직접 checkout을 할 수 있는데

$ git branch
PS D:\git-week3-assignment-1> git branch
* main

이렇게 보인다. clone 해온 저장소에는 저장된 브랜치들이 있는데 보이지 않는다.

$ git branch -a

-a 옵션을 사용하면 브랜치들을 모두 볼 수 있다.

PS D:\git-week3-assignment-1> git branch
* main
remotes/origin/HEAD -> origin/main
remote/origin/main
remote/origin/yeonghui

원하는 upstream 브랜치로 이동하고자 한다면 checkout 할 수 있다.

$ git checkout origin/yeonghui
  • 임시로 브랜치로 이동하는 것으로 로컬 브랜치 생성은 안된다.
$ git switch 
  • remote에 이미 같은 이름이 있는 경우, 같은 이름으로 로컬에 만들어준다.
$ git checkout -b yeonghui origin/yeonghui
  • -b [로컬브랜치 명] 사용하면 로컬 브랜치를 만들 수 있다.
$ git checkout --track origin/yeonghui
  • remote 저장소에 브랜치 이름을 그대로 로컬 브랜치로 생성한다.

checkout , switch 는 무엇인가?

$ git checkout 브랜치이름
  • checkout : 현재 브랜치에서 다른 브랜치로 이동하는 명령어
  • 깃은 향후 충돌을 방지하려고 워킹 디렉터리에 작업이 남아 있다면 경고 메시지를 보여 주고 브랜치를 변경할 수 없게 제한한다.
$ git switch [<options>] [--no-guess] <branch>
$ git switch [<options>] --detach [<start-point>]
$ git switch [<options>] (-c|-C) <new-branch> [<start-point>]
$ git switch [<options>] --orphan <new-branch>
$ git switch -c test
Switched to a new branch 'test'

git switch -c test
fatal: A branch named 'test' already exists.

$ git switch -C test
Reset branch 'test'
  • $ -c <new-branch> : 새로운 브랜치 생성 이미 존재하는 경우 생성 X
  • $ -C <new-branch> : 새로운 브랜치 생성 이미 존재하는 경우 리셋

git-scm switch git-scm checkout

다음에는

local에 clone 했을 경우와 fork해서 clone했을 경우 다른 점이 무엇인지 실행하고 정리

results matching ""

    No results matching ""