Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Version control system (git + gitolite)

2024-10-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Foreword:

Introduction to Git

Linus created the open source Linux in 1991. Since then, the Linux system has evolved into the largest server system software. Although Linus created Linux, Linux grew with the participation of enthusiastic volunteers around the world, so many people wrote code for Linux around the world. In 2005, in order to solve the problem of source code development and management of Linux system, Linus spent two weeks writing a distributed version control system in C, which is Git, the most advanced distributed version control system in the world. In 2008, the GitHub website was launched, it provided free Git storage for open source projects, and numerous open source projects began to migrate to GitHub, including jQuery,PHP,Ruby, and Git quickly became the most popular distributed version control system. (at present, most Linux have their own git software.)

Introduction to Gitolite

If it is not for collaborative development with others, Git does not need to set up a server at all. Git can use the path of the local version library directly to complete the operation between git version libraries locally. But if you need to share version libraries with others and collaborate on development, you need to be able to operate Git libraries through specific network protocols. Git supports a wide range of protocols and there are many options for setting up servers, and different schemes have their own advantages and disadvantages. Gitolite is a lightweight open source project that uses SSH public key authentication to achieve branch-level access control. For individuals, small and medium-sized enterprises and some open source projects, the services provided by Gitolite are sufficient if there are no special requirements.

Gitolite installation

Experimental environment:

Gitolite server:

[root@linux-node1-gitolite-server ~] # cat / etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

[root@linux-node1-gitolite-server ~] # ifconfig | awk 'NR==2 {print $2}'

172.16.48.132

1. Install the appropriate dependent environment

[root@linux-node1-gitolite-server ~] # yum install perl openssh git-y

two。 Create git users to generate public and private keys for managing gitolite

[root@linux-node1-gitolite-server ~] # useradd git

[root@linux-node1-gitolite-server ~] # echo git | passwd-- stdin git

[root@linux-node1-gitolite-server ~] # ssh-keygen

[root@linux-node1-gitolite-server ~] # cp / root/.ssh/id_rsa.pub / tmp/admin.pub

3. Switch to the git user to create the installation directory

[root@linux-node1-gitolite-server ~] # su-git

[git@linux-node1-gitolite-server ~] $mkdir bin

4. Download the gitolite source code

[git@linux-node1-gitolite-server ~] $git clone https://github.com/sitaramc/gitolite.git

5. Install gitolite

[git@linux-node1-gitolite-server] $. / gitolite/install-to / home/git/bin/

[git@linux-node1-gitolite-server ~] $/ home/git/bin/gitolite setup-Competition / tmp/admin.pub

6. Switch to root user, clone gitolite-admin.git

[git@linux-node1-gitolite-server ~] $su-root

[root@linux-node1-gitolite-server ~] # git clone git@172.16.48.132:gitolite-admin.git

7. So far, the gitolite-admin directory under clone, that is, gitolite has been installed successfully.

[root@linux-node1-gitolite-server ~] # ls

Anaconda-ks.cfg gitolite-admin

Note: gitolite authorizes the warehouse by managing gitolite-admin.

1. Conf is the configuration file directory

2. Keydir is the git client public key directory

Collaborative use

Developer 1 server configuration:

[root@linux-node0-manager ~] # cat / etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

[root@linux-node0-manager ~] # ifconfig | awk 'NR==2 {print $2}'

172.16.48.129

1. Generate public and private keys on the developer 1 server

[root@linux-node0-manager] # ssh-keygen-f ~ / .ssh/chentaicheng

[root@linux-node0-manager] # ls ~ / .ssh/

Chentaicheng chentaicheng.pub

two。 Store the public key chentaicheng.pub in the gitolite-admin/keydir directory of the gitolite server

[root@linux-node0-manager] # scp-P22-r-p ~ / .ssh/chentaicheng.pub root@172.16.48.132:gitolite-admin/keydir

3. Access to the warehouse profile

Configure the repository and permissions for chentaicheng keys on the gitolite server:

1. Check whether chentaicehng.pub exists in the gitolite-admin/keydir directory

[root@linux-node1-gitolite-server keydir] # pwd

/ root/gitolite-admin/keydir

[root@linux-node1-gitolite-server keydir] # ls

Admin.pub chentaicheng.pub

[root@linux-node1-gitolite-server keydir] #

two。 Configure the repository corresponding to the chentaicheng key

3. Configure git

[root@linux-node1-gitolite-server gitolite-admin] # pwd

/ root/gitolite-admin

[root@linux-node1-gitolite-server gitolite-admin] # git config-- global user.email "chentaicheng@qq.com"

[root@linux-node1-gitolite-server gitolite-admin] # git config-- global user.name "chentaicheng"

4. Update the modified configuration and public key to the gitolite server

[root@linux-node1-gitolite-server gitolite-admin] # git add *

[root@linux-node1-gitolite-server gitolite-admin] # git commit-m 'add new repo ctc by chentaicheng'

[root@linux-node1-gitolite-server gitolite-admin] # git push

Check whether developer 1 can get read and write access to the warehouse ctc

Clone ctc warehouse and add content, then submit to remote warehouse

[root@linux-node0-manager ~] # git clone gitolite:ctc

Cloning into 'ctc'...

Enter passphrase for key'/ root/.ssh/chentaicheng':

Warning: You appear to have cloned an empty repository.

[root@linux-node0-manager ~] # ls

Anaconda-ks.cfg ctc

[root@linux-node0-manager ~] # cd ctc/

[root@linux-node0-manager ctc] # git config-- global user.email "791582297@qq.com"

[root@linux-node0-manager ctc] # git config-- global user.name "CTC"

[root@linux-node0-manager ctc] # git add readme.txt

[root@linux-node0-manager ctc] # git commit-m 'add readme.txt'

[root@linux-node0-manager ctc] # git push origin master

At this point, the git+gitolite is deployed.

Developer 2 gets the code of developer 1push

Developer 2 environment:

[root@linux-node2-develop ~] # cat / etc/redhat-release

CentOS Linux release 7.4.1708 (Core)

[root@linux-node2-develop ~] # ifconfig | awk 'NR==2 {print $2}'

172.16.48.133

1. Generate a key pair on the developer 2 host and transfer the key to the gitolite-admin/keydir directory of the gitolite service

[root@linux-node2-develop ~] # mkdir .ssh

[root@linux-node2-develop ~] # ssh-keygen-f. SSH / develop

[root@linux-node2-develop] # scp-P22 root@172.16.48.132:gitolite-admin/keydir

two。 Configure the repository corresponding to the develop key

3. Gitolite modifies the configuration file and updates it to the gitolite server so that developer 2 has read and write access to the ctc repository.

[root@linux-node1-gitolite-server gitolite-admin] # pwd

/ root/gitolite-admin

[root@linux-node1-gitolite-server gitolite-admin] # git add *

[root@linux-node1-gitolite-server gitolite-admin] # git commit-m 'add develop'

[root@linux-node1-gitolite-server gitolite-admin] # git push

4. Developer 2 gets the code of developer 1push

[root@linux-node2-develop ~] # git clone gitolite:ctc

[root@linux-node2-develop ~] # ls

Anaconda-ks.cfg ctc

[root@linux-node2-develop ~] # cd ctc/

[root@linux-node2-develop ctc] # ls

Readme.txt

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report