* Shallow clone of a specific git revision?
@ 2024-11-12 12:24 Michal Suchánek
2024-11-13 10:23 ` Toon Claes
0 siblings, 1 reply; 6+ messages in thread
From: Michal Suchánek @ 2024-11-12 12:24 UTC (permalink / raw)
To: git
Hello,
Looking through clone man page it supports shallow clones of branches
and tags only.
Would it be possible to do shallow clone of a specific revision,
and checkout specific revision on clone?
Thanks
Michal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shallow clone of a specific git revision?
2024-11-12 12:24 Shallow clone of a specific git revision? Michal Suchánek
@ 2024-11-13 10:23 ` Toon Claes
2024-11-13 10:29 ` Michal Suchánek
0 siblings, 1 reply; 6+ messages in thread
From: Toon Claes @ 2024-11-13 10:23 UTC (permalink / raw)
To: Michal Suchánek, git
Michal Suchánek <msuchanek@suse.de> writes:
> Hello,
>
> Looking through clone man page it supports shallow clones of branches
> and tags only.
>
> Would it be possible to do shallow clone of a specific revision,
> and checkout specific revision on clone?
Hi Michal,
I'm working on a patch, and I've submitted a first version [1] a little
while ago to allow users to pass a reference on git-clone(1). Would this
change fit your needs, or what else would you like to support?
--
Toon
[1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shallow clone of a specific git revision?
2024-11-13 10:23 ` Toon Claes
@ 2024-11-13 10:29 ` Michal Suchánek
2024-11-15 5:00 ` David Aguilar
0 siblings, 1 reply; 6+ messages in thread
From: Michal Suchánek @ 2024-11-13 10:29 UTC (permalink / raw)
To: Toon Claes; +Cc: git
On Wed, Nov 13, 2024 at 11:23:47AM +0100, Toon Claes wrote:
> Michal Suchánek <msuchanek@suse.de> writes:
>
> > Hello,
> >
> > Looking through clone man page it supports shallow clones of branches
> > and tags only.
> >
> > Would it be possible to do shallow clone of a specific revision,
> > and checkout specific revision on clone?
>
> Hi Michal,
>
> I'm working on a patch, and I've submitted a first version [1] a little
> while ago to allow users to pass a reference on git-clone(1). Would this
> change fit your needs, or what else would you like to support?
> [1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/
Hello,
that slightly expands the available options but it does not make it
possible to clone an arbitrary revision, ie. specified by a SHA
Thanks
Michal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shallow clone of a specific git revision?
2024-11-13 10:29 ` Michal Suchánek
@ 2024-11-15 5:00 ` David Aguilar
2024-11-15 9:37 ` Jeff King
2024-11-15 10:43 ` Michal Suchánek
0 siblings, 2 replies; 6+ messages in thread
From: David Aguilar @ 2024-11-15 5:00 UTC (permalink / raw)
To: Michal Suchánek; +Cc: Toon Claes, git
On Wed, Nov 13, 2024 at 11:29:48AM +0100, Michal Suchánek wrote:
> On Wed, Nov 13, 2024 at 11:23:47AM +0100, Toon Claes wrote:
> > Michal Suchánek <msuchanek@suse.de> writes:
> >
> > > Hello,
> > >
> > > Looking through clone man page it supports shallow clones of branches
> > > and tags only.
> > >
> > > Would it be possible to do shallow clone of a specific revision,
> > > and checkout specific revision on clone?
> >
> > Hi Michal,
> >
> > I'm working on a patch, and I've submitted a first version [1] a little
> > while ago to allow users to pass a reference on git-clone(1). Would this
> > change fit your needs, or what else would you like to support?
>
> > [1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/
>
> Hello,
>
> that slightly expands the available options but it does not make it
> possible to clone an arbitrary revision, ie. specified by a SHA
>
> Thanks
>
> Michal
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.
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.
cheers,
--
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shallow clone of a specific git revision?
2024-11-15 5:00 ` David Aguilar
@ 2024-11-15 9:37 ` Jeff King
2024-11-15 10:43 ` Michal Suchánek
1 sibling, 0 replies; 6+ messages in thread
From: Jeff King @ 2024-11-15 9:37 UTC (permalink / raw)
To: David Aguilar; +Cc: Michal Suchánek, Toon Claes, git
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Shallow clone of a specific git revision?
2024-11-15 5:00 ` David Aguilar
2024-11-15 9:37 ` Jeff King
@ 2024-11-15 10:43 ` Michal Suchánek
1 sibling, 0 replies; 6+ messages in thread
From: Michal Suchánek @ 2024-11-15 10:43 UTC (permalink / raw)
To: David Aguilar; +Cc: Toon Claes, git
Hello,
On Thu, Nov 14, 2024 at 09:00:43PM -0800, David Aguilar wrote:
> On Wed, Nov 13, 2024 at 11:29:48AM +0100, Michal Suchánek wrote:
> > On Wed, Nov 13, 2024 at 11:23:47AM +0100, Toon Claes wrote:
> > > Michal Suchánek <msuchanek@suse.de> writes:
> > >
> > > > Hello,
> > > >
> > > > Looking through clone man page it supports shallow clones of branches
> > > > and tags only.
> > > >
> > > > Would it be possible to do shallow clone of a specific revision,
> > > > and checkout specific revision on clone?
> > >
> > > Hi Michal,
> > >
> > > I'm working on a patch, and I've submitted a first version [1] a little
> > > while ago to allow users to pass a reference on git-clone(1). Would this
> > > change fit your needs, or what else would you like to support?
> >
> > > [1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/
> >
> > Hello,
> >
> > that slightly expands the available options but it does not make it
> > possible to clone an arbitrary revision, ie. specified by a SHA
> >
> > Thanks
> >
> > Michal
>
> In case it helps, here's a short recipe demonstrating how to do a
Yes, that's helpful, thanks.
> 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.
This is how many git reatures start, after all. They are provided as a
script on top of core git functionality.
> 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.
I would be fetching from a forge most of the time which would use its own
implementation of git server most of the time but it's good to know what
the options are on the canonical implementation at least.
Thanks
Michal
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-15 10:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-12 12:24 Shallow clone of a specific git revision? Michal Suchánek
2024-11-13 10:23 ` Toon Claes
2024-11-13 10:29 ` Michal Suchánek
2024-11-15 5:00 ` David Aguilar
2024-11-15 9:37 ` Jeff King
2024-11-15 10:43 ` Michal Suchánek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox