본문 바로가기

Git/Git & Git Hub

GitHub 특정 Branch Clone 하기

# 특정 Branch를 Clone 하는 방법

- 보통은 신규로 Repository를 생성하면 master branch가 main branch로 설정 되어 있다.

새로운 브랜치를 생성하여 작업을 분리하기도 하는데, 대표적으로는 dev, stage, prd 등 개발- 스테이징- 운영 등의 작업을 구분하여 저장소를 운영한다.

여기서는 특정 branch의 소스 코드를 Clone하는 방법에 대해서 알아보자.

# 브랜치를 지정하지 않고 clone을 하게되면 master가 default로 clone이 된다.

$ git clone -b <branch명> <remote_repo 주소>

# 특정 브랜치를 지정하여 clone한 결과는 아래와 같다.

# git clone -b <branch명> <remote_repo 주소>

$ git clone -b test https://github.com/project007/test.git
Cloning into 'test'...
Username for 'https://github.com': ooooo
Password for 'https://oooooo@github.com':
remote: Enumerating objects: 22, done.
remote: Counting objects: 100% (22/22), done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 1084 (delta 21), reused 34 (delta 10), pack-reused 3032
Receiving objects: 100% (1084/1084), 2.22 MiB | 0 bytes/s, done.
Resolving deltas: 100% (1299/1299), done.

- 끝 -

'Git > Git & Git Hub' 카테고리의 다른 글

remote 변경 (git remote 변경)  (0) 2024.03.19
! [rejected] master -> master (fetch first)  (0) 2024.03.19
Git Default 브랜치 변경하기  (0) 2023.03.08
Git Error 해결  (0) 2022.11.28
Git Clone과 Pull의 차이점  (0) 2022.08.18