Use this API to update Git submodules.

Update a submodule reference

PUT /api/v4/projects/{id}/repository/submodules/{submodule}

Updates a reference for a specified submodule. Used in workflows, especially automated ones, to keep other projects that use the submodule up to date.

Parameters

NameTypeDescription
id
Path, required
StringID or URL-encoded path of the project
Example: gitlab-org/gitlab
submodule
Path, required
StringURL-encoded full path to the submodule, for example lib%2Fclass%2Erb
Example: gitlab-org/gitlab-shell

Request body (application/json)

PropertyTypeDescription
branch
Required
StringName of the branch to commit into
Example: main
commit_messageStringCommit message. If omitted, a default message is used
Example: Commit message
commit_sha
Required
StringFull commit SHA to update the submodule to
Example: ed899a2f4b50b4370feeea94676502b42383c746

Responses

CodeDescriptionSchema
200OKAPIEntitiesCommitDetail
400The repository is empty—
401401 Unauthorized—
404404 Project Not Found—

Schemas

Objects returned by the operations above and objects nested in their request bodies.

APIEntitiesCommitDetail

PropertyTypeDescription
author_emailStringEmail address of the commit author
Example: john@example.com
author_nameStringName of the commit author
Example: John Smith
authored_dateString (date-time)Date and time when the commit was authored
Example: 2012-05-28T04:42:42-07:00
committed_dateString (date-time)Date and time when the commit was committed
Example: 2012-05-28T04:42:42-07:00
committer_emailStringEmail address of the committer
Example: jack@example.com
committer_nameStringName of the committer
Example: Jack Smith
created_atString (date-time)Date and time when the commit was created. Identical to committed_date
Example: 2017-07-26T11:08:53.000+02:00
extended_trailersObjectGit trailers parsed from the commit message, with every value for each key
Example: {"Signed-off-by":["John Doe \u003cjohndoe@gitlab.com\u003e","Jane Doe \u003cjanedoe@gitlab.com\u003e"]}
idStringFull SHA of the commit
Example: 2695effb5807a22ff3d138d593fd856244e155e7
last_pipelineObjectLatest pipeline for the commit
messageStringFull commit message
Example: Initial commit
parent_idsArray of stringsSHAs of the parent commits
Example: ["2a4b78934375d7f53875269ffd4f45fd83a84ebe"]
project_idInteger (int64)Example: 1
short_idStringShort SHA of the commit
Example: 2695effb
statsAPIEntitiesCommitStatsNumber of lines added and deleted in the commit, and their total. Returned only when stats is true, which is the default where the endpoint supports it
statusStringStatus of the latest pipeline for the commit
Example: success
titleStringTitle of the commit message
Example: Initial commit
trailersObjectGit trailers parsed from the commit message. Duplicate keys include the last value only
Example: {"Merged-By":"Jane Doe janedoe@gitlab.com"}
web_urlStringURL to view the commit in the GitLab UI
Example: https://gitlab.example.com/janedoe/gitlab-foss/-/commit/ed899a2f4b50b4370feeea94676502b42383c746

APIEntitiesCommitStats

PropertyTypeDescription
additionsIntegerExample: 1
deletionsIntegerExample: 0
totalIntegerExample: 1