Create Git repository

This function creates a new Git™ repository on a cPanel account.

Important:

The system logs errors for this function in the ~/.cpanel/logs/vc_TIMESTAMP_git_create.log file, where TIMESTAMP represents the time of the error in Unix epoch time.

Authorizations:
query Parameters
name
required
string

The new repository's display name.

Example: name=example
repository_root
required
string <path>

The absolute path to the directory in which to store the repository, relative to the user's home directory.

Note:

  • If the directory does not exist, the system will create it.
  • If the specified directory already contains a repository, the system will automatically add it to the list of cPanel-managed repositories.
  • This feature enforces several restrictions on repository paths. For more information, read our Guide to Git - For System Administrators documentation.
Example: repository_root=/home/user/public_html/example
type
required
string

The repository type.

  • git — A Git repository.

Note:

git is the only possible value.

Value: "git"
Example: type=git
object

A JSON-formatted object containing information about the source repository that the system will clone.

Note:

If you do not include source repository data, the function creates an empty repository.

Example: source_repository={"remote_name":"origin","url":"ssh://clone.domain.com/cloneme"}

Responses

Response Schema: application/json
apiversion
integer

The version of the API.

func
string

The name of the method called.

module
string

The name of the module called.

object

Request samples

uapi --output=jsonpretty \
  --user=username \
  VersionControl \
  create \
  type='git' \
  name='example' \
  repository_root='/home/user/public_html/example'

Response samples

Content type
application/json
{
  • "apiversion": 3,
  • "func": "create",
  • "module": "VersionControl",
  • "result": {
    • "data": {
      • "available_branches": [
        • "master",
        • "olive"
        ],
      • "branch": "master",
      • "clone_urls": {},
      • "last_update": null,
      • "name": "example",
      • "repository_root": "/home/user/public_html/example",
      • "source_repository": {},
      • "tasks": [
        • {
          • "action": "create",
          • "args": {
            • "log_file": "/home/username/.cpanel/logs/vc_1234567890.123456_git_deploy.log",
            • "repository_root": "/home/user/example"
            },
          • "id": "00000000/5a9ec8dd4c345d",
          • "sse_url": "/sse/UserTasks/B3A27B96-51F7-11E8-92E3-CC90C4F823F0",
          • "subsystem": "VersionControl"
          }
        ],
      • "type": "git"
      },
    • "errors": null,
    • "messages": null,
    • "metadata": { },
    • "status": 1,
    • "warnings": null
    }
}