We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.10.10. Working with Git

If you need your repository to be inaccessible to outsiders and all actions with it are completely controlled by you, you can create your own Git server by following the steps described below.

Git on the hosting is installed by default:

Follow these steps:

  1. Change to your home directory:
    cd ~
  2. Create a directory for your Git project:
    mkdir repo.git
  3. Change to the created directory:
    cd repo.git
  4. Create an empty Git repository (parameter bare creates a repository without a working directory, you cannot execute commands from the server git add, commit etc.:
    git init --bare
  5. Check if the repository directories have been created by running the command ls:

There are two main approaches to creating a Git repository:

  1. Importing an existing project or directory into Git.
  2. Cloning an existing repository from the server with the command git clone.

Let's use the first one.

Follow these steps:

  1. Create a directory for the Git project in the user's home directory and change to it by running the commands:
    cd ~
    mkdir repo
    cd repo
  2. Initialize the repository:
    git init
  3. Check what was created in the repository directory by running the command ls -a:This directory is where you work with the project files, and the hidden .git directory contains all of your project's Git history and meta information, including all objects (commits, trees, blobs, tags), all pointers to various branches, and more.
  4. Create 3 test files:
    touch index.php index1.php index2.php
  5. Add files to the index:
    git add .
  6. Commit the files:
    git commit -m 'First commit'
  7. Add the remote repository:
    git remote add developer login@host:/home/name_hosting_account/repo.git
  8. Check what changes will be sent to the server:
    git status

    You can see that the current branch is master and 3 new empty files will be uploaded to the server.

  9. Upload files from your local PC from the master branch to the developer server:
    git push developer master
  10. If you need to get changes from the server, use the command:
    git pull developer master

To avoid entering the SSH password each time you connect to a remote server, configure key authentication.