A detailed tutorial on building a private Git server on linux

  • 2021-08-17 01:52:46
  • OfStack

1. Server build

The remote warehouse is actually no different from the local warehouse, purely for 7x to boot up 24 hours a day and exchange everyone's modifications. GitHub is a remote repository that hosts open source code for free. However, for some commercial companies that regard source code as life, they don't want to disclose the source code and are reluctant to pay protection fees for GitHub, so they can only build an Git server as a private warehouse.

To build Git server, we need to prepare a machine running Linux, and we use CentOS here. Here are the installation steps:

1. Download git-2. 22.0. tar. gz

https://Github.com/Git/Git/archive/v2.22.0.tar.gz

Use Xftp to put the installation package on the server

2. Install git service environment preparation


yum -y install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel gcc cc

1) Decompress, switch the position where the git installation package is placed, and decompress


tar  In fact, in fact, the zxvf git-2.22.0.tar.gz

2) Switch directories


cd git-2.22.0

3) autoconf

4)./configure

5) Compile (it takes 1 minute to wait patiently)


make

6) Installation


make install

3. Add users


adduser -r -c 'git version control' -d /home/git -m git

This command creates the/home/git directory as the git user's home directory.

4. Set the password


passwd git

Enter the password twice

5. Switch to git user


su git

6. Create an git repository

mkdir repo1 Create Warehouse Folder

git--bare init initialization repository.

Note: If you do not use the "--bare" parameter, after initializing the repository, submit the master branch to report an error. This is because git rejects the push operation by default, requiring. git/config to add the following code:


[receive]

   denyCurrentBranch = ignore

Recommended: git--bare init to initialize the repository.

2. Connect to the server

After the private git server is built, it can be used to connect to github1, but our git server is not configured with a key login, so you need to enter a password every time you connect.

1. If you use TortoiseGit synchronization, refer to the following usage method.

Connect using commands:


 $ git remote add origin ssh://git@192.168.25.156/home/git/first

This form doesn't seem to be the same as the one just used, with the prefix ssh://. Well, you can also write this:


tar  In fact, in fact, the zxvf git-2.22.0.tar.gz
0

If you use TortoiseGit synchronization, refer to the above usage method.

2. Git bash here cloning steps


tar  In fact, in fact, the zxvf git-2.22.0.tar.gz
1

ip Address 192.168. 25.156

/home/git/repo1 Path plus warehouse name

Summarize


Related articles: