Git manager feature

Git Manager allows users to create and host Git repositories on the DA server or sync with the remote repository. The feature can be reached via Advanced Features -> Git.

Installation

If git is not present on your system: On Debian/Ubuntu, run:

apt-get -y install git

On CentOS/RHEL and other RedHat based distros:

yum -y install git

If you run CloudLinux, run this additionally:

cagefsctl --addrpm git
cagefsctl --force-update

Usage

Click on Create Repository in Git manager and then enter your data. name is required but remote and keyfile are optional parameters.

Hosting a repository on DA server requires only the name parameter while syncing with a remote repository requires remote to be set and optionally keyfile to SSH key if it's a private repo. Remote can be any of Git-supported protocols however only SSH is supported in a case of a private repo. Webhooks are supported for remotely synced repositories - triggering a webhook does automated fetch and deploy if both deploy branch and directory are set and valid.

Example

Let's click on Create Repository and enter just a name:

Create View

Then we click on Create Repository. In the main view we can see our newly created repository:

Repos View

The right-hand side contains a tooltip available to execute commands quickly without entering into the repository view:

Repos Tooltip

Clicking on the repository name is going to open its view. There we can see more information about the repository such as all branches available, deployment branch, deploy directory and other details:

Repo Info View

Let's clone the repository assuming we have access to the server via an SSH password if that's allowed or a key:

> git clone john@directadmin.com:domains/example.com/your-repo-name.git
Cloning into 'your-repo-name'...
john@directadmin.com's password:
warning: You appear to have cloned an empty repository.
> echo hello world > readme
> git add readme
> git commit -m "Add readme"
[master (root-commit) 030897a] Add readme
 1 file changed, 1 insertion(+)
 create mode 100644 readme
> git push
john@directadmin.com's password:
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 213 bytes | 213.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To directadmin.com:domains/example.com/your-repo-name.git
 * [new branch]      master -> master

Now let's click on Modify, select master branch, and enter the deploy directory. The deploy directory path must be already present and also relative to the user's home directory:

Repo Modify View

Let's hit Save and then Deploy. Upon confirming that the parameters were valid and deployment went well we can confirm that at the receiving end:

> john@directadmin:~$ ls -l relative/to/home/dir/
total 4
-rw-r--r-- 1 john john 12 Nov  4 08:54 readme
> john@directadmin:~$ cat relative/to/home/dir/readme
hello world

In order to view the history of the repository we click Logs:

Repo Log View

Here we can see our commit message, date, and commit hash. Let's click on the commit:

Repo Diff View

Here we can see the diff of the commit against its parent, message, author, date.

Technical

Repositories are placed under the domain path as name.git such as /home/USER/domains/DOMAIN/name.git.

Repositories are initialized and cloned as bare repositories meaning that deploy is simply just git checking out the working tree. Metadata about the repositories is stored in a per-user SQLite at /usr/local/direcadmin/data/users/USER/user.db.

Deploy directory and keyfile parameters must be provided as relative paths, the user's home path is used as a base.

Entering only a name is the same as git init. Entering remote parameter makes it operate as git clone. If the repository is private then the keyfile must be provided. Keyfile is simply a path to the SSH key. If no keyfile is provided and the repository is private then id_rsa is used automatically.

Each repository has a post-update hook, such as:

/usr/local/directadmin/directadmin git-deploy --gitdir='/home/user/domains/domain.com/name.git' --branch='main' --deploydir='relative/path/to/home'

Triggering the hook above is going to deploy the repository at /home/USER/relative/path/to/home where USER is the current user executing the command. Root execution is not allowed.

Last Updated: