Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to clone directly into a git tag using -b <tagname>

Tags:

git

I'm a bit puzzled why I'm unable to checkout a tag directly from the git clone command. What I try to do is:

git clone -b mytag <url>/foo.git

The error I get is:

warning: Remote branch mytag not found in upstream origin, using HEAD instead

Tag is present and e.g.

cd foo && git checkout mytag 

...works well.

If anyone could share some light on why it's impossible to clone directly into a tag I would appreciate it. Thank you.

like image 866
grm Avatar asked Aug 09 '10 08:08

grm


1 Answers

Perhaps all you really need/want to do is use git archive to pull a tarball of anything git rev-parse can understand. You can use the --remote option to pull the archive from some remote source identically to the <url>/foo.git value that you are passing to clone. In theory, this will be much quicker since all you will be grabbing is the working tree and not the entire repository.

Here's a "works for me" example:

% git archive --prefix foo/ --remote <url>/foo.git my-tag | tar -xf -
like image 60
Brian Phillips Avatar answered Nov 12 '22 22:11

Brian Phillips