카테고리 없음

Git Checkout vs Git Switch

cpnubplzhelp 2024. 8. 27. 15:34

Git Checkout

git checkout 명령어는 브랜치 전환과 특정 커밋으로 이동, 파일의 상태 복원 등을 하는데 사용된다. 

 

 

Git - git-checkout Documentation

When there is only one argument given and it is not -- (e.g. git checkout abc), and when the argument is both a valid (e.g. a branch abc exists) and a valid (e.g. a file or a directory whose name is "abc" exists), Git would usually ask you to disambiguate.

git-scm.com

 

브랜치 전환

git checkout branch-name

 

새 브랜치 생성 및 전환

git checkout -b new-branch-name

 

특정 커밋으로 이동

git checkout commit-hash

 

 

Git Switch

git switch 명령어는 브랜치 전환과 브랜치 생성에 특화된 Git 명령어이다.

git switch의 기능들은 모두 git checkout으로 작업할 수 있으나,

git switch는 는 브랜치 전환과 생성에 초점을 맞추어 명령어의 목적이 명확하다.

 

 

What's the difference between 'git switch' and 'git checkout' <branch>?

Git 2.23 introduces a new command git switch. After reading the documentation, it seems pretty much the same as git checkout <branchname>. What is the difference or use case? Two new commands &

stackoverflow.com

 

브랜치 전환

git switch branch-name

 

새 브랜치 생성 및 전환

git switch -c new-branch-name

 

 

git switch는 브랜치와 관련된 작업만을 수행하는 반면, git checkout은 여러 작업을 지원하여 사용이 복잡할 수 있다.

 

Stackoverflow에서는 git checkout은 스위스 칼처럼 많은것들을 할 수 있는 도구라고 설명하고 있으며, git switch는 branch를 다루는데 특화된 나이프라고 설명하고 있다.