HOWTO · Git

특정 Git 분기 복제

이 문서에서는 원격 저장소에서 특정 git 분기를 복제하는 방법을 설명합니다.

이 기사에서는 모든 분기를 가져오고 특정 분기를 체크아웃하여 원격 저장소에서 특정 git 분기를 복제하는 방법에 대해 설명합니다.

모든 분기를 가져오고 특정 분기에 체크 아웃하여 원격 리포지토리에서 특정 Git 분기 복제

mastergh-pages라는 두 가지 분기가 포함된 원격 저장소를 복제한 다음 gh-pages 분기로 전환합니다.

<!-- The command to use is -->
git clone <remote-repo-url>

<!-- From your terminal run -->
git clone https://github.com/KEVINAMAYI/AkanNameGenerator.git

출력:

Cloning into 'AkanNameGenerator'...
remote: Enumerating objects: 94, done.
remote: Total 94 (delta 0), reused 0 (delta 0), pack-reused 94
Unpacking objects: 100% (94/94), 2.38 MiB | 1.86 MiB/s, done.

프로젝트 폴더로 이동하여 아래 명령을 사용하여 사용 가능한 분기를 나열합니다.

<!-- get into project folder -->
cd AkanNameGenerator

<!-- List branches available -->
git branch -a

출력:

<!-- The asterix indicates we are on branch main -->
* main
remotes/origin/HEAD -> origin/main
remotes/origin/gh-pages
remotes/origin/main

아래 명령을 사용하여 특정 분기 gh-pages로 전환합니다.

git checkout gh-pages

다음을 실행하여 특정 분기 gh-pages에 있는지 확인합니다.

git branch

출력:

<!-- The asterix indicates we are now on branch gh-pages -->
* gh-pages
main

원격 리포지토리에서 직접 특정 Git 분기 복제

Git 명령에 분기 이름을 지정하여 원격 저장소에서 직접 필요한 특정 분기를 복제합니다.

<!-- The command to use is -->
git clone --branch <branchname> --single-branch <remote-repo-url>

<!-- From your terminal run -->
git clone --branch gh-pages --single-branch https://github.com/KEVINAMAYI/AkanNameGenerator.git

출력:

Cloning into 'AkanNameGenerator'...
remote: Enumerating objects: 94, done.
remote: Total 94 (delta 0), reused 0 (delta 0), pack-reused 94
Unpacking objects: 100% (94/94), 2.38 MiB | 231.00 KiB/s, done.

프로젝트 폴더로 이동하여 다음을 실행하여 사용 가능한 분기를 나열합니다.

<!-- get into project folder -->
cd AkanNameGenerator

<!-- List branches available -->
git branch -a

출력:

<!-- we have only our specific branch -->
* gh-pages