From: Sean Allred Date: Thu, 24 Nov 2022 16:52:21 GMT Subject: Re: git download Message-ID: <87zgcgs2ne.fsf@gmail.com> In-Reply-To: Vasilij Demyanov 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/// GitLab's pattern is similar: https://gitlab.com//-/raw// 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