Can I share a link for downloading a specific file in my public GitHub repository?

3

Just like the question says... I am looking for a free version control system that allows me to share individual scripts out of a larger project.

So, can GitHub or BitBucket do something like this? Is it possible to have a public repository with many scripts, and send someone a link for downloading an individual script?

jake9115

Posted 2013-10-16T18:16:54.553

Reputation: 1 029

Answers

9

In GitHub, if you view a file, there is a link to the raw-version of the file.

It should look like this:

https://github.com/user/repository/raw/branch/filename

When you replace the blankets, with the real filename etc, than you can download it with curl or wget. So you could send this link to share this file. But it won't have version-control features from git etc.

Christian

Posted 2013-10-16T18:16:54.553

Reputation: 6 571

Now, is there a way to request an earlier version of the file? – Mikhail T. – 2015-03-10T04:20:38.140

You can use the commit ID to get an earlier version https://github.com/user/repository/raw/{commitID}/filename – Sthe – 2015-10-12T23:39:42.837

1Note that you should copy the link that "Raw" points to rather than the resulting page. It will be of the format https://github.com/{user}/{repo}/raw/{branch}/{path}. If you click the link, it will redirect you to a page which requires a token and the path is slightly different: https://raw.github.com/{user}/{repo}/raw/{branch}/{path}?token={token}. Giving it the wrong token will result in a "Not Found" page, thus you should use the first URL. – Senseful – 2016-07-05T18:19:55.077

Oh man, that is just perfect, I want to give you extra points. – jake9115 – 2013-10-16T18:44:33.333

You are welcome. Nice that it works. – Christian – 2013-10-16T19:18:15.600