Re: Shallow clone of a specific git revision?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 14, 2024 at 09:00:43PM -0800, David Aguilar wrote:

> In case it helps, here's a short recipe demonstrating how to do a
> shallow "clone" of a specific commit ID:
> 
>     git init the-repo
>     cd ./the-repo
>     git remote add origin <url>
>     git fetch --depth=1 origin <commit-id>
>     git checkout <commit-id>
> 
> It'd be nice to add this feature to "git clone" for convenience.

Agreed on all parts of this, but wanted to mention one thing here:

> This recipe depends on the server's configuration. You must have one of
> the following configuration variables set "true" server-side in order
> for the server to accept requests for arbitrary commit IDs:
> 
>     uploadpack.allowReachableSHA1InWant
>         Allow upload-pack to accept a fetch request that asks for an
>         object that is reachable from any ref tip. However, note that
>         calculating object reachability is computationally expensive.
>         Defaults to false. Even if this is false, a client may be able
>         to steal objects via the techniques described in the "SECURITY"
>         section of the gitnamespaces(7) man page; it’s best to keep
>         private data in a separate repository.
> 
>     uploadpack.allowAnySHA1InWant
>         Allow upload-pack to accept a fetch request that asks for any
>         object at all. Defaults to false.

In the v2 protocol, the reachability checks are gone (as if allowAny was
set). So if the server speaks v2, your instructions should just work.
Most servers should be new enough to support this (and certainly big
forges like GitHub and GitLab do), though note that for git-over-ssh the
server side might need to configure ssh to allow the correct environment
variables. There's discussion in the GIT_PROTOCOL section of git(1).

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux