From: Jeff King <peff@peff.net>
To: Josh Triplett <josh@joshtriplett.org>
Cc: git@vger.kernel.org, Jamey Sharp <jamey@minilop.net>
Subject: Re: Cloning a remote tag without using git-fetch-pack directly?
Date: Wed, 20 Apr 2011 02:26:54 -0400 [thread overview]
Message-ID: <20110420062653.GE28597@sigill.intra.peff.net> (raw)
In-Reply-To: <20110419222050.GA3304@feather>
On Tue, Apr 19, 2011 at 03:20:53PM -0700, Josh Triplett wrote:
> Using fetch-pack, I can clone a single tag from a repository:
>
> /tmp/testrepo$ git init
> Initialized empty Git repository in /tmp/testrepo/.git/
> /tmp/testrepo$ git fetch-pack /home/josh/src/linux-2.6/.git refs/tags/v2.6.12
I don't think there is any reason to use fetch-pack here instead of
fetch. The latter will handle other non-git protocols like dumb http and
git-over-http.
> However, I can't seem to find any way to convince git clone to do the
> same thing for me. git clone will clone a branch, but not a tag.
>
> /tmp/testrepo$ git clone /home/josh/src/linux-2.6/.git -b refs/tags/v2.6.12
> Cloning into linux-2.6...
> done.
> warning: Remote branch refs/tags/v2.6.12 not found in upstream origin, using HEAD instead
Right. There is no way to do what you want with clone. The "-b" option
is not "just clone this one thing", it is "clone everything, but the
branch I am interested in is ...". The fetch refspec remains
"+refs/heads/*:refs/remotes/origin/*".
To clone a subset of a repository, you have to do the init+fetch trick,
as you did above. If you want the configuration set up by clone, you
can do that, too, with "git config". So the equivalent commands to the
clone you want are:
git init linux-2.6
cd linux-2.6
git config remote.origin.url /home/josh/src/linux-2.6
git config remote.origin.fetch refs/tags/v2.6.12
git fetch origin
We could make clone more flexible with respect to such things, but I
don't know how useful that would be. A very small minority of power
users want to use weird fetch refspecs, and it is simple enough to
configure them manually, as above.
> On a different note, git fetch-pack seems to silently fail if asked to
> fetch a remote tag which points at a tree object rather than a commit
> object:
>
> /tmp/testrepo$ git init
> Initialized empty Git repository in /tmp/testrepo/.git/
> /tmp/testrepo$ git fetch-pack /home/josh/src/linux-2.6/.git refs/tags/v2.6.12-tree
> (1) /tmp/testrepo$ echo $?
> 1
Did you mean v2.6.11-tree? There is no v2.6.12-tree in standard
linux-2.6 repositories. So fetch-pack is failing because there are no
matching refs to fetch. This works for me:
$ git init
$ git fetch-pack /home/peff/compile/linux-2.6 refs/tags/v2.6.11-tree
remote: Counting objects...
...
If you want better error messages, use the fetch porcelain:
$ git init
$ git fetch /home/peff/compile/linux-2.6 refs/tags/v2.6.12-tree
fatal: Couldn't find remote ref refs/tags/v2.6.12-tree
fatal: The remote end hung up unexpectedly
-Peff
next prev parent reply other threads:[~2011-04-20 6:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 22:20 Cloning a remote tag without using git-fetch-pack directly? Josh Triplett
2011-04-20 6:26 ` Jeff King [this message]
2011-04-20 7:27 ` Josh Triplett
2011-04-20 7:38 ` Jeff King
2011-04-20 7:40 ` Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110420062653.GE28597@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=jamey@minilop.net \
--cc=josh@joshtriplett.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).