Skip to content

Instantly share code, notes, and snippets.

@OlegGorj
Created October 9, 2018 23:28
Show Gist options
  • Save OlegGorj/09ff30309040a844553168079a37c571 to your computer and use it in GitHub Desktop.
Save OlegGorj/09ff30309040a844553168079a37c571 to your computer and use it in GitHub Desktop.

Normally it's not possible to download just one file from git without downloading the whole repository as suggested in the first answer. It's because Git doesn't store files as you think (as CVS/SVN do), but it generates them based on the entire history of the project.

But there are some workarounds for specific cases. See below:

GitHub

If this file is on github.com, try e.g.:

wget https://raw.githubusercontent.com/user/project/master/README GitWeb

If you're using Git on the Server - GitWeb, then you may try in example (change it into the right path):

wget "http://example.com/gitweb/?p=example;a=blob_plain;f=README.txt;hb=HEAD" GitWeb at drupalcode.org

Example:

wget "http://drupalcode.org/project/ads.git/blob_plain/refs/heads/master:/README.md" googlesource.com

There is an undocumented feature that allows you to download base64-encoded versions of raw files:

curl "https://chromium.googlesource.com/chromium/src/net/+/master/http/transport_security_state_static.json?format=TEXT" | base64 --decode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment