Re: git download

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

 



On Wed, Nov 23, 2022 at 9:27 AM Vasilij Demyanov <qvasic@xxxxxxxxx> wrote:
>
> Hello everybody!
>

Hi,

> I have a need to get just one file from a repository, it would be
> useful to have a command something like this:
>

Ok.

> git download repo_url branch_or_commit path/to/file
>
> Or maybe there is something like this, I just haven't found it in the docs?
>

So this isn't something git itself provides. Various web hosting
services for git provide such access, because they allow viewing the
repository contents. Git can't provide this easily because of the
nature of the commits and trees used to store the contents of the
repository. In order to verify that you got the correct contents, you
essentially have to fetch the commit and all its parents. You can
maybe save some download space by using a sparse clone.. but most
remote repositories may not allow arbitrary commit hash fetching.

If you already have a repository available from some computer/system
you can extract the file at a given version via something like git
cat-file:

$ git cat-file -p <commitish>:<path>

where commitish can be a branch or a commit hash, or other way to
reference a commit, and path is the path of the file.

Unfortunately you will essentially need to have cloned the repository first.

If your project is hosted somewhere using software like github,
gitlab, etc, or has gitweb-like software operating on it, you may be
able to find an API or web interface that lets you extract the
individual file without downloading the repository. This is somewhat
outside the scope of this mailing list tho.

Thanks,
Jake

> Best regards,
> Vasyl



[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