From git-clone (1) Manual Page
--branch
kann auch Tags nehmen und das HEAD bei diesem Commit im resultierenden Repository entfernen.
Ich habe es versucht
git clone --branch <tag_name> <repo_url>
Aber es funktioniert nicht. Es gibt zurück:
warning: Remote branch 2.13.0 not found in upstream Origin, using HEAD instead
Wie benutzt man diesen Parameter?
git clone --branch <tag_name> <repo_url>
Dieser Befehl wird in Git 1.7.9.5 nicht unterstützt.
Ich benutze Git 1.8.3.5 und es funktioniert
Verwenden --single-branch
Option auf nur der Klonverlauf führt zum Tipp des Tags. Dies erspart das Klonen von unnötigem Code.
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
Wird schneller sein als:
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
Oder
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
Verwenden Sie den Befehl
git clone --help
um zu sehen, ob dein Git den Befehl unterstützt
git clone --branch tag_name
Wenn nicht, machen Sie einfach folgendes:
git clone repo_url
cd repo
git checkout tag_name