# Create Git repository

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

* For more information about support for version control in cPanel & WHM, read our
Git Version Control and
Guide to Git documentation.
* For a list of configuration changes, repository restrictions, and troubleshooting steps,
read our Guide to Git - For System Administrators documentation.

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.

Endpoint: GET /VersionControl/create
Version: 11.136.0.13
Security: BasicAuth

## Query parameters:

  - `name` (string, required)
    The new repository's display name.
    Example: "example"

  - `repository_root` (string, required)
    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: "/home/user/public_html/example"

  - `type` (string, required)
    The repository type.

* git — A Git repository.

Note:

git is the only possible value.
    Enum: "git"

  - `source_repository` (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: {"remote_name":"origin","url":"ssh://clone.domain.com/cloneme"}

## Response 200 fields (application/json):

  - `apiversion` (integer)
    The version of the API.
    Example: 3

  - `func` (string)
    The name of the method called.
    Example: "create"

  - `module` (string)
    The name of the module called.
    Example: "VersionControl"

  - `result` (object)

  - `result.data` (object)

  - `result.data.available_branches` (array)
    An list of available branches for the cloned or existing repository, if any exist.
    Example: ["master","olive"]

  - `result.data.branch` (string,null)
    The repository's current branch.

* null — The system has not finished the clone process for
the repository, or no local branches exist.
    Example: "master"

  - `result.data.clone_urls` (object)
    An object containing URLs to use to clone the repository.

  - `result.data.clone_urls.read_only` (array)
    A list of clone URLs with read-only permissions. The function
returns a blank array if the account does not include the
Shell Access setting.

Important:

If the server uses a [nonstandard SSH port](https://go.cpanel.net/firewall),
the system returns a clone URL that includes the port number.
    Example: ["https://user@example.com/home/user/example"]

  - `result.data.clone_urls.read_write` (array)
    A list of of clone URLs with read-write permissions. The function
returns a blank array if the account does not include the
Shell Access setting.

Important:

If the server uses a [nonstandard SSH port](https://go.cpanel.net/firewall),
the system returns a clone URL that includes the port number.
    Example: ["ssh://user@example.com/home/user/example"]

  - `result.data.last_update` (any)
    Information about the most-recent (HEAD) commit for the current branch.

Note:

* The system may require a large amount of time to clone large
repositories. Until this process finishes, HEAD information is unavailable.
* null is the only possible value.
    Enum: null

  - `result.data.name` (string)
    The repository's display name.
    Example: "example"

  - `result.data.repository_root` (string)
    The absolute path of the directory that contains the repository in the user's home directory.
    Example: "/home/user/public_html/example"

  - `result.data.source_repository` (object)
    A object containing information about a cloned repository's source
repository.

Note:

The function only returns this object if it will clone a
repository.

  - `result.data.source_repository.remote_name` (string)
    The source repository's name.
    Example: "remote"

  - `result.data.source_repository.url` (string)
    The source repository's clone URL.
    Example: "http://user@domain.com/home/user/domain"

  - `result.data.tasks` (array)
    An array of objects containing information about the
[Task Queue](https://go.cpanel.net/whmdocsTaskQueueMonitor)
system's process that will clone the repository.

Note:

The function only returns this value if it will clone a
repository.

  - `result.data.tasks.action` (string)
    The task's action.

* create

Note:

create is the only possible value.
    Enum: "create"

  - `result.data.tasks.args` (object)
    A list of arguments for the
[Task Queue](https://go.cpanel.net/whmdocsTaskQueueMonitor)
system's process.

  - `result.data.tasks.args.log_file` (string)
    The absolute path to the process's log file.

Note:

The function only returns this value if the process
generated a log file.
    Example: "/home/username/.cpanel/logs/vc_1234567890.123456_git_deploy.log"

  - `result.data.tasks.args.repository_root` (string)
    The absolute path to the repository's directory within the user's home directory.
    Example: "/home/user/example"

  - `result.data.tasks.id` (string)
    The [Task Queue](https://go.cpanel.net/whmdocsTaskQueueMonitor)
system's task ID number.
    Example: "00000000/5a9ec8dd4c345d"

  - `result.data.tasks.sse_url` (string)
    The SSE interface to track the progress of the process.
    Example: "/sse/UserTasks/B3A27B96-51F7-11E8-92E3-CC90C4F823F0"

  - `result.data.tasks.subsystem` (string)
    The [Task Queue](https://go.cpanel.net/whmdocsTaskQueueMonitor)
subsystem that will handle the task.

* VersionControl

Note:

VersionControl is the only possible value.
    Enum: "VersionControl"

  - `result.data.type` (string)
    The repository type.

* git — A Git repostiory.

Note:

git is the only possible value.
    Example: "git"

  - `result.errors` (array,null)
    List of errors if the API failed.

  - `result.messages` (array,null)
    List of messages generated by the API.

  - `result.metadata` (object)

  - `result.status` (integer)
    * 1 — Success.
* 0 — Failed. Check the errors field for more details.
    Enum: 1, 0

  - `result.warnings` (array,null)
    List of warnings generated by the API. Warnings describe non-critical failures or other problematic conditions noted while running a API.


