Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="https://stackoverflow.com/users/46058/jakub-narebski">Jakub</a> already mentioned a <a href="https://stackoverflow.com/questions/2586824/partial-clone-with-git-and-mercurial">shallow clone of selected branches is possible</a>, but quite complex to do.<br> And he added:</p> <blockquote> <p>Note however that because branches usually share most of their history, the gain from cloning only a subset of branches might be smaller than you think.</p> </blockquote> <p>I would add that you shouldn't have any VCS tool in a production plateform (you only install/monitor what is necessary for the production to <em>run</em>).<br> So <a href="http://www.kernel.org/pub/software/scm/git/docs/git-archive.html" rel="nofollow noreferrer"><code>git archive</code></a> remains the best way to extract just what you need, as an archive (<code>zip</code> or <code>tar</code>, format that you can then uses without Git, once transferred on the production side)</p> <hr> <p>Update March 2012:</p> <p>the <a href="https://lkml.org/lkml/2012/3/28/418" rel="nofollow noreferrer">upcoming git1.7.10</a> (April 2012) will actually allow you to clone only one branch:</p> <pre><code>git clone --single-branch </code></pre> <p>You can see it in <a href="https://github.com/git/git/blob/master/t/t5500-fetch-pack.sh" rel="nofollow noreferrer"><code>t5500-fetch-pack.sh</code></a>:</p> <pre><code>test_expect_success 'single branch clone' ' git clone --single-branch "file://$(pwd)/." singlebranch ' </code></pre> <p>That feature was then fixes with:</p> <ul> <li><a href="https://github.com/git/git/commit/31b808a03290a4f87c571cc1c61f26d8a03c7025" rel="nofollow noreferrer">commit 31b808a03290a4f87c571cc1c61f26d8a03c7025</a> (Ralf Thielow, Git 1.7.12.3, Oct. 2012)</li> </ul> <h2><code>clone --single</code>: limit the fetch refspec to fetched branch</h2> <blockquote> <p>After running "<code>git clone --single</code>", the resulting repository has the usual default "<code>+refs/heads/*:refs/remotes/origin/*</code>" wildcard fetch refspec installed, which means that a subsequent "<code>git fetch</code>" will end up grabbing all the other branches.</p> <p>Update the fetch refspec to cover only the singly cloned ref instead to correct this.</p> </blockquote> <ul> <li><a href="https://github.com/git/git/commit/60a5f5fc791d6c133732238736ef0961df600296" rel="nofollow noreferrer">commit 60a5f5f</a> (<a href="https://github.com/gitster" rel="nofollow noreferrer">Junio C Hamano (<code>gitster</code>)</a>, Git 2.0.2, July 2014)</li> </ul> <h2>builtin/clone.c: detect a clone starting at a tag correctly</h2> <blockquote> <p><a href="https://github.com/git/git/commit/31b808a03290a4f87c571cc1c61f26d8a03c7025" rel="nofollow noreferrer">31b808a</a> (<code>clone --single</code>: limit the fetch refspec to fetched branch, 2012-09-20) tried to see if the given "branch" to follow is actually a tag at the remote repository by checking with "<code>refs/tags/</code>" but it incorrectly used <code>strstr(3)</code>; it is actively wrong to treat a "branch" "<code>refs/heads/refs/tags/foo</code>" and use the logic for the "<code>refs/tags/</code>" ref hierarchy.<br> What the code really wanted to do is to see if it starts with "<code>refs/tags/</code>".</p> </blockquote> <hr> <p>Update Sept 2016: <a href="https://stackoverflow.com/a/39527106/6309"><code>git clone --single-branch --branch tag</code> will work for chained tags</a> in Git 2.11+ (Q4 2016).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload