How to serve static files from GitHub
Like many developers out there, you might use GitHub to store your source code. When you’re building something pretty simple like a Web application, HTML files, JavaScript code, CSS stylesheets, etc., it could be useful to directly distribute your file through HTTP.
The Naive Approach
You probably tried the first simple approach, which is using GitHub directly as your content distributor. You could use an URL such as https://raw.githubusercontent.com/twbs/bootstrap/main/js/src/button.js to include the JavaScript file as part of your Web site.
Except that won’t work. A good reason for it to fail is that GitHub does not set the right Content-Type header according to the file type.
The file type ain’t text/plain for sure. It should be application/javascript , and the fact that it’s not returned correctly will prevent your browser from loading it for security reasons.
Statically to the Rescue
Statically is a content delivery network (CDN) that can serve files directly from GitHub, GitLab, or Bitbucket. You don’t need to create any account to use Statically, and the service is free — though you can donate to sponsor them — which makes it straightforward to use.

To use Statically, simply replace the https://raw.githubusercontent.com prefix in your GitHub URL by https://cdn.statically.io/gh and you’re done.
Serving the same file through Statically returns the correct Content-Type this time, allowing it to be loaded by a Web browser.
Caveats
Statically caches files for one year, except if the files are retrieved from a branch named main , master or dev — in that case, they are only cached for one day. This is important to notice as you might get crazy while testing your files as they are not reloaded from GitHub but are served from the cache.
A caching delay this long might not be a problem for resources you don’t update often. However, if it is an issue, you should replace the branch name in the URL with a commit SHA id, e.g., https://cdn.statically.io/gh/twbs/bootstrap/85208ae5570aeefe4e94c1ceb29ca3b6ffdf83a1/js/src/button.js .
Use Case
For Mergify, we used this technique to embed our annoying cookies consent popup on our Web site.

The code is made of a JavaScript and a CSS file and is hosted on GitHub. With Statically, we’ve been able to embed the files directly without deploying them anywhere else. We can git push our changes and see them appear on our website 24 hours later (or before if we change the URL ).
Сведения о репозиториях
Репозиторий содержит все файлы проекта и журнал редакций для каждого файла. Вы можете обсудить работу над проектом и управлять ею в репозитории.
About repositories
You can own repositories individually, or you can share ownership of repositories with other people in an organization.
You can restrict who has access to a repository by choosing the repository’s visibility. For more information, see «About repository visibility.»
For user-owned repositories, you can give other people collaborator access so that they can collaborate on your project. If a repository is owned by an organization, you can give organization members access permissions to collaborate on your repository. For more information, see «Permission levels for a personal account repository» and «Repository roles for an organization.»
With GitHub Free for personal accounts and organizations, you can work with unlimited collaborators on unlimited public repositories with a full feature set, or unlimited private repositories with a limited feature set. To get advanced tooling for private repositories, you can upgrade to GitHub Pro, GitHub Team, or GitHub Enterprise Cloud. For more information, see «GitHub’s plans.»
You can use repositories to manage your work and collaborate with others.
- You can use issues to collect user feedback, report software bugs, and organize tasks you’d like to accomplish. For more information, see «About issues.»
- You can use GitHub Discussions to ask and answer questions, share information, make announcements, and conduct or participate in conversations about a project. For more information, see «About discussions.»
- You can use pull requests to propose changes to a repository. For more information, see «About pull requests.»
- You can use project boards to organize and prioritize your issues and pull requests. For more information, see «About projects (classic).»
Repositories and individual files are subject to size limits. For more information, see «About large files on GitHub»
To learn how to use repositories most effectively, see «Best practices for repositories.»
About repository visibility
You can restrict who has access to a repository by choosing a repository’s visibility: public or private.
When you create a repository, you can choose to make the repository public or private. Repositories in organizations that use GitHub Enterprise Cloud and are owned by an enterprise account can also be created with internal visibility. For more information, see the GitHub Enterprise Cloud documentation.
- Public repositories are accessible to everyone on the internet.
- Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.
Organization owners always have access to every repository created in an organization. For more information, see «Repository roles for an organization.»
People with admin permissions for a repository can change an existing repository’s visibility. For more information, see «Setting repository visibility.»
Limits for viewing content and diffs in a repository
Certain types of resources can be quite large, requiring excessive processing on GitHub. Because of this, limits are set to ensure requests complete in a reasonable amount of time.
Most of the limits below affect both GitHub and the API.
Text limits
GitHub displays formatted previews of some files, such as Markdown and Mermaid diagrams. GitHub always attempts to render these previews if the files are small (generally less than 2 MB), but more complex files may time out and either fall back to plain text or not be displayed at all. These files are always available in their raw formats, which are served through raw.githubusercontent.com ; for example, https://raw.githubusercontent.com/octocat/Spoon-Knife/master/index.html . Click the Raw button to get the raw URL for a file.
Diff limits
Because diffs can become very large, we impose these limits on diffs for commits, pull requests, and compare views:
- In a pull request, no total diff may exceed 20,000 lines that you can load or 1 MB of raw diff data.
- No single file’s diff may exceed 20,000 lines that you can load or 500 KB of raw diff data. Four hundred lines and 20 KB are automatically loaded for a single file.
- The maximum number of files in a single diff is limited to 300.
- The maximum number of renderable files (such as images, PDFs, and GeoJSON files) in a single diff is limited to 25.
Some portions of a limited diff may be displayed, but anything exceeding the limit is not shown.
Commit listings limits
The compare view and pull requests pages display a list of commits between the base and head revisions. These lists are limited to 250 commits. If they exceed that limit, a note indicates that additional commits are present (but they’re not shown).
What do raw.githubusercontent.com URLs represent?
raw.githubusercontent.com is a domain name used by GitHub to serve raw files directly from their repositories. These URLs can be used to access the content of a file without having to clone the entire repository. In this guide, we will discuss what raw.githubusercontent.com URLs represent and provide some code examples to show how to use them.
Code Examples
Using cURL
One of the easiest ways to access raw files from GitHub is by using cURL. Here’s an example:
In this example, you need to replace the following placeholders:
: the GitHub username of the repository owner : the name of the repository : the name of the branch where the file is located : the path to the file inside the repository
For instance, if you want to access the file `example.txt` from the `main` branch of the `myusername/myrepo` repository, you would use the following URL:
Using wget
Another command-line tool that can be used to download files from raw.githubusercontent.com is wget:
The placeholders to replace in this URL are the same as in the previous example.
Using a Programming Language
If you prefer to use a programming language to access the content of a file from GitHub, you can use any HTTP client library to make a GET request to the raw.githubusercontent.com URL. Here’s an example using Python:
You can replace the placeholders in the URL and the variables passed to the `format()` method according to your needs.
How do I view RAW files on GitHub?
First, we need to find the data file in GitHub. That’s simply a matter of navigating through the directory tree in a repository until we’re able to open up a preview of the contents. Then, right click (or control-click) on the Raw button on the top right, and save the link address.
Where are GitHub wikis stored?
Wikis are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud and GitHub Enterprise Server.
How do I edit a Wikipedia page on GitHub?
Editing wiki pages
- On GitHub, navigate to the main page of the repository.
- Under your repository name, click Wiki.
- Using the wiki sidebar, navigate to the page you want to change.
- Use the text editor edit the page’s content.
- Type a commit message describing your changes.
- To commit your changes to the wiki, click Save Page.
How do I create a raw GitHub repository?
How to Host Files on Github
- Step 1: Go to github.com and sign-up for a free account, if you don’t have one.
- Step 2: Click the “New Repository” button, or go to github.com/new, to create a new repository for hosting your files.
- Step 3: Give your repository a name and a description and click the Create button.
What is raw GitHub user content?
The raw.githubusercontent.com domain is used to serve unprocessed versions of files stored in GitHub repositories. The URL in your question references the install file in the master branch of the Homebrew/install repository. The rest of that command just retrieves the file and runs ruby on its contents.
How do I connect to existing Git repository?
- Create a repository on GitHub, without a README, completely empty.
- In your existing repository: git remote add REMOTENAME URL . You could name the remote github , for example, or anything else you want.
- Push from your existing repository: git push REMOTENAME BRANCHNAME .
How do I create a remote URL?
Ist Step:- Change the current working directory to your local project. 2nd Step:- List your existing remotes in order to get the name of the remote you want to change. Change your remote’s URL from HTTPS to SSH with the git remote set-url command. 4th Step:- Now Verify that the remote URL has changed.
How do you set up a remote origin?
Switching remote URLs from HTTPS to SSH
- Open Terminal .
- Change the current working directory to your local project.
- Change your remote’s URL from HTTPS to SSH with the git remote set-url command. $ git remote set-url origin [email protected]:USERNAME/REPOSITORY.git.
- Verify that the remote URL has changed.
How do I setup a remote Git repository?
To add a new remote, use the git remote add command on the terminal, in the directory your repository is stored at. The git remote add command takes two arguments: A unique remote name, for example, “my_awesome_new_remote_repo” A remote URL, which you can find on the Source sub-tab of your Git repo.
How do I get git origin?
If you’ve copied a project from Github, it already has an origin. You can view that origin with the command git remote -v, which will list the URL of the remote repo.
What is origin in git command?
In Git, “origin” is a shorthand name for the remote repository that a project was originally cloned from. More precisely, it is used instead of that original repository’s URL – and thereby makes referencing much easier.
Is Origin the master branch?
origin/master is an entity (since it is not a physical branch) representing the state of the master branch on the remote origin . origin master is the branch master on the remote origin . So we have these: origin/master ( A representation or a pointer to the remote branch)
What is difference between origin and master in git?
Origin: This is the name of a remote. A remote in Git is a common repository that all team members use to exchange their changes. Master: This is a branch name where we first initiate git and then we use to make commits. And the changes in the master can pull/push into a remote.
What is git origin branch?
origin is the default name given to the remote repository from which your local repository was cloned. origin/master is the master branch of that repository, which (by default) your local master branch will track.
How do I pull an origin branch?
- Reset your local master to match the remote repository’s master (WARNING: be sure that you don’t have any uncommitted changes you want to keep before issuing the following command): git reset –hard origin/master.
- Fetch all remote branches into your local repository: git fetch origin.
How do I open a git branch?
The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.
How do I push to a new branch?
Check your branch
- Create and checkout to a new branch from your current commit: git checkout -b [branchname]
- Then, push the new branch up to the remote: git push -u origin [branchname]
Can Git branch names have spaces?
The “create branch” example in the “Referencing issues in your development work” section of the documentation contains a space, but git does not allow spaces in branch names!
What is a valid branch name?
A Git branch name can not: Have a path component that begins with . Have a double dot .. Have an ASCII control character,
How long can a branch name be?
A two or three short-word descriptions about the branch. Try not to go beyond three words, as you may end up having long branch name. Use three words only if you don’t have the need of using tag name.