class Github::Repos::Contents

as Base64 encoded content.
These API methods let you retrieve the contents of files within a repository

def archive(*args)


"ref" => "master"
"archive_format" => "tarball",
github.repos.contents.archive 'user-name', 'repo-name',
github = Github.new
= Examples

* :ref - Optional string - valid Git reference, defaults to master
* :archive_format - Required string - either tarball or zipball
= Parameters

Note: For private repositories, these links are temporary and expire quickly.

a second GET request.
to follow redirects or you will need to use the Location header to make
archive for a repository. Please make sure your HTTP framework is configured
This method will return a 302 to a URL to download a tarball or zipball

Get archive link
def archive(*args)
  arguments(args, :required => [:user, :repo])
  params         = arguments.params
  archive_format = params.delete('archive_format') || 'zipball'
  ref            = params.delete('ref') || 'master'
  get_request("/repos/#{user}/#{repo}/#{archive_format}/#{ref}", params)
end

def create(*args)


message: "my commit message"
content: "puts 'hello ruby'",
path: 'hello.rb',
github.repos.contents.create 'user-name', 'repo-name', 'path',
github = Github.new
= Examples

* committer.email - string - The email of the committer of the commit
* committer.name - string - The name of the committer of the commit
* author.email - string - The email of the author of the commit
* author.name - string - The name of the author of the commit

receive a 500 status code.
you choose to use author or committer. Otherwise, you’ll
You must provide values for both name and email, whether

information is omitted, the authenticated user’s information is used.
committer information if omitted. If the committer
The author section is optional and is filled in with the

= Optional Parameters
uses the repository’s default branch (usually master)
* :branch - Optional string - The branch name. If not provided,
which will be Base64 encoded
* :content - Requried string - The new file content,
* :message - Requried string - The commit message
* :path - Requried string - The content path
= Parameters

This method creates a new file in a repository

Create a file
def create(*args)
  arguments(args, :required => [:user, :repo, :path]) do
    assert_required REQUIRED_CONTENT_OPTIONS
  end
  params = arguments.params
  params.strict_encode64('content')
  put_request("/repos/#{user}/#{repo}/contents/#{path}", params)
end

def delete(*args)


sha: "329688480d39049927147c162b9d2deaf885005f"
message: "delete hello.rb file",
path: 'hello.rb',
github.repos.contents.delete 'user-name', 'repo-name', 'path',
github = Github.new
= Examples

* committer.email - string - The email of the committer of the commit
* committer.name - string - The name of the committer of the commit
* author.email - string - The email of the author of the commit
* author.name - string - The name of the author of the commit

receive a 500 status code.
you choose to use author or committer. Otherwise, you’ll
You must provide values for both name and email, whether

information is omitted, the authenticated user’s information is used.
committer information if omitted. If the committer
The author section is optional and is filled in with the

= Optional Parameters
uses the repository’s default branch (usually master)
* :branch - Optional string - The branch name. If not provided,
* :sha - Requried string - The blob SHA of the file being removed.
* :message - Requried string - The commit message
* :path - Requried string - The content path
= Parameters

This method deletes a file in a repository

Delete a file
def delete(*args)
  arguments(args, :required => [:user, :repo, :path]) do
    assert_required %w[ path message sha ]
  end
  delete_request("/repos/#{user}/#{repo}/contents/#{path}", arguments.params)
end

def get(*args)


github.repos.contents.get path: 'README.md'
github = Github.new user: 'user-name', repo: 'repo-name'

github.repos.contents.get 'user-name', 'repo-name', 'path'
github = Github.new
= Examples

* :ref - Optional string - valid Git reference, defaults to master
= Parameters

This method returns the contents of any file or directory in a repository.

Get contents
def get(*args)
  arguments(args, :required => [:user, :repo, :path])
  params = arguments.params
  get_request("/repos/#{user}/#{repo}/contents/#{path}", params)
end

def readme(*args)


content.readme
content = Github::Repos;:Contents.new user: 'user-name', 'repo-name'

github.repos.contents.readme 'user-name', 'repo-name'
github = Github.new
= Examples

This method returns the preferred README for a repository.

Get the README
def readme(*args)
  arguments(args, :required => [:user, :repo])
  params = arguments.params
  get_request("/repos/#{user}/#{repo}/readme", params)
end

def update(*args)


sha: "25b0bef9e404bd2e3233de26b7ef8cbd86d0e913"
message: "my commit message",
content: "puts 'hello ruby again'",
path: 'hello.rb',
github.repos.contents.update 'user-name', 'repo-name', 'path',
github = Github.new
= Examples

uses the repository’s default branch (usually master)
* :branch - Optional string - The branch name. If not provided,
* :sha - Requried string - The blob SHA of the file being replaced.
which will be Base64 encoded
* :content - Requried string - The new file content,
* :message - Requried string - The commit message
* :path - Requried string - The content path
= Parameters

This method updates a file in a repository

Update a file
def update(*args)
  create(*args)
end