Skip to content

Repositories

无闻 edited this page Aug 28, 2015 · 35 revisions

Repositories

List your repositories

List repositories that are accessible to the authenticated user.

This includes repositories owned by the authenticated user, repositories where the authenticated user is a collaborator, and repositories that the authenticated user has access to through an organization membership.

GET /user/repos
Response
Status: 200 OK
Content-Type: application/json
[
  {
    "id": 2,
    "owner": {
      "id": 1,
      "username": "unknwon",
      "full_name": "",
      "email": "[email protected]",
      "avatar_url": "/avatars/1"
    },
    "full_name": "unknwon/macaron",
    "private": false,
    "fork": false,
    "html_url": "http://localhost:3000/unknwon/macaron",
    "clone_url": "http://localhost:3000/unknwon/macaron.git",
    "ssh_url": "jiahuachen@localhost:unknwon/macaron.git",
    "permissions": {
      "admin": true,
      "push": true,
      "pull": true
    }
  },
  {
    "id": 8,
    "owner": {
      "id": 2,
      "username": "org1",
      "full_name": "org1",
      "email": "[email protected]",
      "avatar_url": "/avatars/2"
    },
    "full_name": "org1/gogs",
    "private": false,
    "fork": false,
    "html_url": "http://localhost:3000/org1/gogs",
    "clone_url": "http://localhost:3000/org1/gogs.git",
    "ssh_url": "jiahuachen@localhost:org1/gogs.git",
    "permissions": {
      "admin": true,
      "push": true,
      "pull": true
    }
  }
]

Create

Create a new repository for the authenticated user.

POST /user/repos

Create a new repository in this organization. The authenticated user must be a owner of the specified organization.

POST /orgs/:org/repos
Parameters
Name Type Description
name string Required The name of the repository
description string A short description of the repository
private bool Either true to create a private repository, or false to create a public one. Default is false
auto_init bool Pass true to create an initial commit with README. Default is false
gitignore string Desired language .gitignore template to apply. Use the name of the template. For example, "Go".
license string Desired LICENSE template to apply. Use the name of the template. For example, "Apache v2 License" or "MIT License".
Example
{
  "name": "Hello-World",
  "description": "This is your first repository",
  "private": false
}
Response
Status: 201 Created
Content-Type: application/json
{
  "id": 27,
  "owner": {
    "id": 1,
    "username": "unknwon",
    "full_name": "",
    "email": "[email protected]",
    "avatar_url": "/avatars/1"
  },
  "full_name": "unknwon/Hello-World",
  "private": false,
  "fork": false,
  "html_url": "http://localhost:3000/unknwon/Hello-World",
  "clone_url": "http://localhost:3000/unknwon/hello-world.git",
  "ssh_url": "jiahuachen@localhost:unknwon/hello-world.git",
  "permissions": {
    "admin": true,
    "push": true,
    "pull": true
  }
}
Clone this wiki locally