Re: git download

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

 



Vasilij Demyanov <qvasic@xxxxxxxxx> writes:

> I have a need to get just one file from a repository, it would be
> useful to have a command something like this:
>
> git download repo_url branch_or_commit path/to/file

My immediate thought was git-archive[1], but depending the specifics of
your needs/setup, you could use curl/wget for this pretty simply. For
example, if you're using GitHub, you can

    curl https://raw.githubusercontent.com/git/git/master/README.md

to dump the content of the README to standard out. As another example,
to get the content of next:builtin/var.c,

    curl https://raw.githubusercontent.com/git/git/next/builtin/var.c

The general pattern:

    https://raw.githubusercontent.com/<repo>/<branch-or-commit>/<file-path>

GitLab's pattern is similar:

    https://gitlab.com/<repo>/-/raw/<branch-or-commit>/<file-path>

e.g.

    curl https://gitlab.com/gitlab-org/git/-/raw/main/README.md

This will be limited to getting a single file at a time. If you want
more, you can make more curl requests, but git-archive can give a whole
directory or even the entire repo at a specific commit. Since
git-archive outputs a tar/zip file, you'll want to combine it with your
favorite decompression tool to get your content.

[1]: https://git-scm.com/docs/git-archive

--
Sean Allred



[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