Git Product home page Git Product logo

github's Introduction

Github.js

Ever wanted to store a file on Github right from the browser? Here you are.

Create a Github instance.

var github = new Github({
  username: "YOU_USER",
  password: "YOUR_PASSWORD",
  auth: "basic"
});

Or if you prefer OAuth, it looks like this:

var github = new Github({
  token: "OAUTH_TOKEN"
  auth: "oauth"
});

Expose API for a given repository.

var repo = github.getRepo(reponame);

Retrieve all available branches (aka heads) of a repository.

repo.listBranches(function(err, branches) {
  
});

Store contents at a certain path, where files that don't yet exist are created on the fly.

repo.write('master', 'path/to/file', 'YOUR_NEW_CONTENTS', 'YOUR_COMMIT_MESSAGE', function(err) {
  
});

Not only can you can write files, you can of course read them.

repo.read('master', 'path/to/file', function(err, data) {
  
});

Move a file from A to B.

repo.move('master', 'path/to/file', 'path/to/new_file', function(err) {
  
});

Remove a file.

repo.remove('master', 'path/to/file', function(err) {
  
});

Listing all files of a repository is easy too.

repo.list('master', 'path/to/file', function(err, data) {
  
});

github's People

Contributors

icebreaker avatar michael avatar neiltron avatar stdclass avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.