Build a git code warehouse in centos7

Build a git code warehouse in centos7

Preface

In the past, when developing my own personal applets, I have always used SVNit as a version control system for the code, but SVNthere is a more obvious disadvantage of using it. The code is managed in the way of a central warehouse, which can only be used when it is connected to the Internet. . And in our daily learning and development is a spiral development process, we need a code control system that is easier to achieve multi-version coexistence.

For the use of Git, please refer to my blog: How Git uploads its own local branch code to the remote master branch

text

Git

Git is a free and open source distributed version control system designed to handle everything from small to large projects quickly and efficiently.

The difference between SVN and GIT :

  • GITIt is distributed, and SVNis centralized.
  • GITThe content according to metadata stored, and SVNis based on the file : Because the directory is in a git clone of the repository on a personal machine, it has all the stuff on the central repository, such as labels, branch, version records.
  • GITBranches and SVNbranches are different : svnbranch omissions will occur, and gityou can quickly switch between several branches in the same working directory. It is easy to find unmerged branches and merge these files simply and quickly.
  • GITThere is not a global version number, but SVNthere is.
  • GITThe integrity of the content is better thanSVN : GITThe content storage uses a SHA-1hash algorithm. This can ensure the integrity of the code content and reduce the damage to the repository in the event of disk failures and network problems.

Build a git code warehouse in centos7

1. Install git

sudo yum install git

After installation, check the gitversion

Insert picture description here

2. Create a dedicated server account for git

  • useradd: Create centosuser
  • passwd: Set a password for this user
useradd luo
passwd luo

3. Create a new git repository
Step 1: Create a folder

mkdir -p /usr/local/mygit/dubbodemo.git

Step 2: Create a new gitbare library

cd /usr/local/mygit/dubbodemo.git

git init --bare

Step 3: Modify permissions

chown -R git:git ../dubbodemo.git
chmod -R 775 ../dubbodemo.git
chmod g+s -R ../dubbodemo.git

4. Use the git client tool to pull or upload the code.
Here is sourcetreean example:
Step 1: Configure the gitwarehouse
Insert picture description here
Step 2: Pull the gitwarehouse

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_40990818/article/details/108818141