git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git clone -b

From
Phil Hord <phil.hord@gmail.com>
Date
Jul 1, 2013, 17:49 UTC
Message-ID
<CABURp0oQ9MNGZecD4mkniXMEUJ5L7Xn+JFQMEgc97Mfe26JYvg@mail.gmail.com>
In-Reply-To
<51D12A0E.60709@atlas-elektronik.com>

It would be nice to support more generic specs for the --branch switch. But it is complicated because the refs have not been fetched yet during the clone, and so normal refs operations -- which expect to work on a local repository -- do not work. So, the ref is looked up locally from a list in expected locations after fetching the remote refs but before the clone occurs. The remote refs which are fetched is not configurable during clone, and so only 'refs/heads/*' is fetched for non-mirrors.

I was able to tweak git-clone to fetch the remote ref when I hacked builtin/clone.c to check in 'refs' and also to extend the refspec to something more broad ("+refs/*:refs/remotes/origin/*"), but this is not a workable solution. But there probably is a more correct way than the hack I tried.

Phil
Previous: Junio C HamanoNext: Jeff King
Message 9 of 10 in “git clone -b”
  1. Stefan NäweJun 28, 2013
  2. Stefan NäweJun 28, 2013
  3. Fredrik GustafssonJun 28, 2013
  4. Stefan NäweJun 28, 2013
  5. Stefan NäweJul 1, 2013
  6. Junio C HamanoJul 1, 2013
  7. Stefan NäweJul 2, 2013
  8. Junio C HamanoJul 2, 2013
  9. Phil HordJul 1, 2013
  10. Jeff KingJul 3, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.