--branch
결과 저장소의 커밋에서 태그를 가져와 HEAD를 분리 할 수도 있습니다.
나는 시도했다
git clone --branch <tag_name> <repo_url>
그러나 작동하지 않습니다. 다음을 반환합니다.
warning: Remote branch 2.13.0 not found in upstream origin, using HEAD instead
이 매개 변수를 사용하는 방법은 무엇입니까?
답변
git clone --branch <tag_name> <repo_url>
이 명령은 git 1.7.9.5에서 지원되지 않습니다.
git 1.8.3.5를 사용하고 작동합니다.
답변
--single-branch
옵션을 사용 하여 태그 끝으로 이어지는 기록 만 복제 하십시오 . 이렇게하면 불필요한 코드가 많이 복제되지 않습니다.
git clone <repo_url> --branch <tag_name> --single-branch
답변
git clone -b 13.1rc1-Gotham --depth 1 https://github.com/xbmc/xbmc.git
Cloning into 'xbmc'...
remote: Counting objects: 17977, done.
remote: Compressing objects: 100% (13473/13473), done.
Receiving objects: 36% (6554/17977), 19.21 MiB | 469 KiB/s
보다 빠를 것입니다 :
git clone https://github.com/xbmc/xbmc.git
Cloning into 'xbmc'...
remote: Reusing existing pack: 281705, done.
remote: Counting objects: 533, done.
remote: Compressing objects: 100% (177/177), done.
Receiving objects: 14% (40643/282238), 55.46 MiB | 578 KiB/s
또는
git clone -b 13.1rc1-Gotham https://github.com/xbmc/xbmc.git
Cloning into 'xbmc'...
remote: Reusing existing pack: 281705, done.
remote: Counting objects: 533, done.
remote: Compressing objects: 100% (177/177), done.
Receiving objects: 12% (34441/282238), 20.25 MiB | 461 KiB/s
답변
명령을 사용하십시오
git clone --help
자식이 명령을 지원하는지 확인
git clone --branch tag_name
그렇지 않은 경우 다음을 수행하십시오.
git clone repo_url
cd repo
git checkout tag_name
답변
특정 태그를 복제하면 ‘분리 된 HEAD’상태 가 반환 될 수 있습니다 .
이 문제를 해결하려면 먼저 저장소를 복제 한 다음 특정 태그를 체크 아웃하십시오. 예를 들면 다음과 같습니다.
repo_url=https://github.com/owner/project.git
repo_dir=$(basename $repo_url .git)
repo_tag=0.5
git clone --single-branch $repo_url # using --depth 1 can show no tags
git --work-tree=$repo_dir --git-dir=$repo_dir/.git checkout tags/$repo_tag
참고 : Git 1.8.5 부터 및 -C <path>
대신 에을 사용할 수 있습니다 .--work-tree
--git-dir