git,

Retrieve a single file with Git

Jun 26, 2023 · 1 min read · Post a comment

Retrieving a single file from a Git repo it’s not possible …yet. However, there are few workarounds that could get the job done.

Prerequisites

  • Git

Solution(s)

git archive Download a single file (README.md in this case) from a remote in current directory:

git archive --remote=[email protected]:foo/bar.git HEAD README.md | tar -x

wget / curl You can always use CLI tools such as wget and curl to download the blob file.

wget <URL> -O testfile
curl <URL>  > testfile

Conclusion

In case you face any issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.

git