ubuntu install git server

one installation

To install Git server on Ubuntu, you need to follow these steps:

  1. Install Git:

    sudo apt-get update sudo apt-get install git
  2. 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
  3. 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.

  4. 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.

  5. 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

Guess you like

Origin blog.csdn.net/wishfly/article/details/129854313