Get file contents
The GitHub Get File Contents tool allows users to retrieve the contents of files or directories directly from any GitHub repository. It supports specifying branches, tags, pull requests, or specific commits to access the exact version of the file or directory you need.
Features
- Fetch file or directory contents from any public GitHub repository.
- Specify the repository owner and repository name to target the desired project.
- Use optional parameters to specify git references such as branches, tags, pull requests, or commit SHAs.
- Supports retrieving entire directories by specifying paths ending with a slash '/'
- Read-only access ensuring safe extraction of content without modifying the source repository.
Benefits
- Easily access and review code or documentation without cloning the repository.
- Improve development workflow by programmatically retrieving files on demand.
- Supports integration with automation tools that require GitHub file data.
- Facilitates code audits, reviews, and content analysis directly from GitHub.
- Saves time and resources by avoiding unnecessary repository cloning.
Description
Get the contents of a file or directory from a GitHub repository
Parameters
5 parameters
| Name | Type | Description |
|---|---|---|
| ownerrequired | string | Repository owner (username or organization) |
| path | string | Path to file/directory (directories must end with a slash '/') |
| ref | string | Accepts optional git refs such as |
| reporequired | string | Repository name |
| sha | string | Accepts optional commit SHA. If specified, it will be used instead of ref |