From: Sean Allred <allred.sean@gmail.com>
To: Vasilij Demyanov <qvasic@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git download
Date: Thu, 24 Nov 2022 10:52:21 -0600 [thread overview]
Message-ID: <87zgcgs2ne.fsf@gmail.com> (raw)
In-Reply-To: <CACtGy4i7Jv+UyjwKOLsMOQwUO81=o98AA5SNwi+=xUB76ehD_g@mail.gmail.com>
Vasilij Demyanov <qvasic@gmail.com> 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
next prev parent reply other threads:[~2022-11-24 17:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 17:17 git download Vasilij Demyanov
2022-11-23 19:14 ` Jacob Keller
2022-11-24 16:52 ` Sean Allred [this message]
2022-11-25 6:06 ` ZheNing Hu
-- strict thread matches above, loose matches on Subject: below --
2017-03-05 20:26 Git download Cory Kilpatrick
2017-03-06 5:33 ` Torsten Bögershausen
2014-06-12 5:16 git merge issues Raghavendra
2014-06-12 6:32 ` git download jinzhao at wingtech.com
2014-06-12 13:18 ` Valdis.Kletnieks at vt.edu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zgcgs2ne.fsf@gmail.com \
--to=allred.sean@gmail.com \
--cc=git@vger.kernel.org \
--cc=qvasic@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.