one installation
To install Git server on Ubuntu, you need to follow these steps:
-
Install Git:
sudo apt-get update sudo apt-get install git
-
Create a Git user and a Git repository directory:
sudo adduser git sudo mkdir /home/git/repo.git sudo chown git:git /home/git/repo.git
-
Initialize the Git repository:
cd /home/git/repo.git sudo git init --bare
Note: What is created here is a bare repository, which does not contain a workspace, but only a version library, suitable for use on a Git server.
-
Add SSH public key:
Generate an SSH public key on the client and add the public key to the server's authorized_keys file. After adding the public key, you can use the SSH protocol to communicate with the server, such as cloning the warehouse, pushing code, and so on.
-
Clone the repository:
Clone the Git repository with the following command on the client:
git clone git@your-server:/home/git/repo.git
Where your-server is the IP address or domain name of the server.
You have now successfully installed a Git server on Ubuntu and can interact with clients. For more advanced configuration and management, consider using third-party Git server software such as GitLab or GitHub.
client and server