📅 2019-Sep-19 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ ⬩ 📚 Archive
Github's URL organization is shown below. This is useful when you need to process or automate linking to Github.
User's home on Github: https://github.com/<user>
Repository's home on Github: https://github.com/<user>/<repo>
Path to a repo file on master
branch: https://github.com/<user>/<repo>/blob/master/<path-to-file>
. The file is rendered inside the Github UI, with syntax highlighting and formatting. Note the blob
parent before the master
branch name.
Path to a repo file on master
branch rendered raw: https://github.com/<user>/<repo>/raw/master/<path-to-file>
. Note the raw
parent before the master
branch name. Github redirects this raw file URL to: https://raw.githubusercontent.com/<user>/<repo>/master/<path-to-file>
.
Path to a repo directory on master
branch: https://github.com/<user>/<repo>/tree/master/<path-to-dir>
. Notice the tree
parent before the master
branch name.
Could you use the same URL prefix for both directories and files? Yes, you can either use tree
or blob
for both. It does not matter. Github will redirect the URLs back so that tree
is used for directories and blob
is used for files.
Path to directory or file in repository in arbitrary branch: https://github.com/<user>/<repo>/blob/<branch-name>/<path-to-dir>
. The URL format is the same even if the branch name itself has slashes.