This package has moved to
github-client. Please update references to it.
Github.js provides a minimal higher-level wrapper around git's plumbing commands, exposing an API for manipulating GitHub repositories on the file level. It is being developed in the context of github-book, an EPUB3 editor for GitHub.
This package can also be used in nodejs or as a requirejs module.
Create a Github instance.
var github =username: "YOU_USER"password: "YOUR_PASSWORD"auth: "basic";
Or if you prefer OAuth, it looks like this:
var github =token: "OAUTH_TOKEN"auth: "oauth";
npm install github-js
var Github = ;var github = Github;
var repo = github;
Show repository information
Get contents at a particular path.
Fork repository. This operation runs asynchronously. You may want to poll for
repo.contents until the forked repo is ready.
Create Pull Request.
var pull =title: messagebody: "This pull request has been automatically generated."base: "gh-pages"head: "michael" + ":" + "prose-patch";repo;
Retrieve all available branches (aka heads) of a repository.
Store contents at a certain path, where files that don't yet exist are created on the fly.
Not only can you can write files, you can of course read them.
You can also read binary files.
Move a file from A to B.
Remove a file.
Exploring files of a repository is easy too by accessing the top level tree object.
If you want to access all blobs and trees recursively, you can add
Given a filepath, retrieve the reference blob or tree sha.
For a given reference, get the corresponding commit sha.
Create a new reference.
var refSpec ="ref": "refs/heads/my-new-branch-name""sha": "827efc6d56897b048c772eb4087f854f46256132";repo;
Delete a reference.
var user = github;
List all repositories of the authenticated user.
List organizations the autenticated user belongs to.
List authenticated user's gists.
Show user information for a particular username. Also works for organizations.
List public repositories for a particular user.
List repositories for a particular organization. Includes private repositories if you are authorized.
List all gists of a particular user. If username is ommitted gists of the current authenticated user are returned.
var gist = github;
Read the contents of a Gist.
Updating the contents of a Git. Please consult the documentation on GitHub.
var delta ="description": "the description for this gist""files":"file1.txt":"content": "updated file contents""old_name.txt":"filename": "new_name.txt""content": "modified contents""new_file.txt":"content": "a new file""delete_this_file.txt": null;gist;
Github.js has the following dependencies:
Include these before github.js :
<script src="lib/underscore-min.js"><script src="lib/base64.js"><script src="github.js">
Switched to a native
request implementation (thanks @mattpass). Adds support for GitHub gists, forks and pull requests.
Adds support for organizations and fixes an encoding issue.
Smart caching of latest commit sha.
Added support for OAuth.
Support for Moving and removing files.
Consider commit messages.