repositories

List all repository trees in a project

Lists all repository files and directories in a specified project. This endpoint can be accessed without authentication if the repository is publicly accessible. This command provides essentially the same features as the git ls-tree command. Use with_last_commit to include the last commit that changed each entry. with_last_commit cannot be combined with recursive.

get/api/v4/projects/{id}/repository/tree

Request

  • Base URL
    https://gitlab.com
  • Auth
    none declared

Path parameters

idstring required

The ID or URL-encoded path of the project

Query parameters

refstring

The name of a repository branch or tag, if not given the default branch is used

pathstring

The path of the tree

recursiveboolean

Used to get a recursive tree

with_last_commitboolean

Include the last commit for each tree entry. Cannot be combined with "recursive"

pageinteger

Current page number

per_pageinteger

Number of items per page

pagination'legacy' | 'keyset' | 'none'

Specify the pagination method ("none" is only valid if "recursive" is true)

page_tokenstring

Record from which to start the keyset pagination

Response

List all repository trees in a project

idstring required
namestring required
typestring required
pathstring required
modestring required

Example response

{
  "id": "a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba",
  "name": "html",
  "type": "tree",
  "path": "files/html",
  "mode": "040000",
  "last_commit": {
    "id": "2695effb5807a22ff3d138d593fd856244e155e7",
    "short_id": "2695effb",
    "created_at": "2017-07-26T11:08:53.000+02:00",
    "parent_ids": [
      "2a4b78934375d7f53875269ffd4f45fd83a84ebe"
    ],
    "title": "Initial commit",
    "message": "Initial commit",
    "author_name": "John Smith",
    "author_email": "john@example.com",
    "authored_date": "2012-05-28T04:42:42-07:00",
    "committer_name": "Jack Smith",
    "committer_email": "jack@example.com",
    "committed_date": "2012-05-28T04:42:42-07:00",
    "trailers": {
      "Merged-By": "Jane Doe janedoe@gitlab.com"
    },
    "extended_trailers": {
      "Signed-off-by": [
        "John Doe <johndoe@gitlab.com>",
        "Jane Doe <janedoe@gitlab.com>"
      ]
    },
    "web_url": "https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746"
  }
}

Changes

No recorded changes to this operation across all 5 revisions of this API.