Linux-Centos下搭建Git服务器

Linux Centos下搭建Git服务器

1. 安装Git

exit
[roy@localhost etc]$ sudo yum install -y git
Loaded plugins: fastestmirror, langpacks
base                                                            | 3.6 kB  00:00:00     
extras                                                          | 3.4 kB  00:00:00     
mysql-connectors-community                                      | 2.5 kB  00:00:00     
mysql-tools-community                                           | 2.5 kB  00:00:00     
mysql56-community                                               | 2.5 kB  00:00:00     
updates                                                         | 3.4 kB  00:00:00     
(1/2): extras/7/x86_64/primary_db                               | 168 kB  00:00:00     
(2/2): updates/7/x86_64/primary_db                              | 5.7 MB  00:00:03     
Loading mirror speeds from cached hostfile
 * base: mirrors.btte.net
 * extras: mirrors.163.com
 * updates: mirrors.btte.net
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be installed
--> Processing Dependency: perl-Git = 1.8.3.1-6.el7_2.1 for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Processing Dependency: perl(Error) for package: git-1.8.3.1-6.el7_2.1.x86_64
--> Running transaction check
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
---> Package perl-Git.noarch 0:1.8.3.1-6.el7_2.1 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================
 Package                  Arch           Version                    Repository    Size
=======================================================================================
Installing:
 git                      x86_64         1.8.3.1-6.el7_2.1          base         4.4 M
Installing for dependencies:
 perl-Error               noarch         1:0.17020-2.el7            base          32 k
 perl-Git                 noarch         1.8.3.1-6.el7_2.1          base          53 k
 perl-TermReadKey         x86_64         2.30-20.el7                base          31 k

Transaction Summary
=======================================================================================
Install  1 Package (+3 Dependent packages)

Total download size: 4.5 M
Installed size: 22 M
Downloading packages:
(1/4): perl-Error-0.17020-2.el7.noarch.rpm                      |  32 kB  00:00:00     
(2/4): perl-Git-1.8.3.1-6.el7_2.1.noarch.rpm                    |  53 kB  00:00:00     
(3/4): perl-TermReadKey-2.30-20.el7.x86_64.rpm                  |  31 kB  00:00:00     
(4/4): git-1.8.3.1-6.el7_2.1.x86_64.rpm                         | 4.4 MB  00:00:00     
---------------------------------------------------------------------------------------
Total                                                     4.5 MB/s | 4.5 MB  00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:perl-Error-0.17020-2.el7.noarch                                   1/4 
  Installing : perl-TermReadKey-2.30-20.el7.x86_64                                 2/4 
  Installing : git-1.8.3.1-6.el7_2.1.x86_64                                        3/4 
  Installing : perl-Git-1.8.3.1-6.el7_2.1.noarch                                   4/4 
  Verifying  : perl-Git-1.8.3.1-6.el7_2.1.noarch                                   1/4 
  Verifying  : perl-TermReadKey-2.30-20.el7.x86_64                                 2/4 
  Verifying  : 1:perl-Error-0.17020-2.el7.noarch                                   3/4 
  Verifying  : git-1.8.3.1-6.el7_2.1.x86_64                                        4/4 

Installed:
  git.x86_64 0:1.8.3.1-6.el7_2.1                                                       

Dependency Installed:
  perl-Error.noarch 1:0.17020-2.el7           perl-Git.noarch 0:1.8.3.1-6.el7_2.1      
  perl-TermReadKey.x86_64 0:2.30-20.el7      

Complete!
[roy@localhost etc]$ 

2. 新建Git用户

[roy@localhost etc]$ su
Password: 
[root@localhost etc]# useradd git
[root@localhost etc]# vi /etc/sudoers

将git用户添加到sudoers中。

3.创建一个git远程仓库

[root@localhost git]# su - git
[git@localhost ~]$ cd /home/git
[git@localhost ~]$ git init --bare tmp.git
Initialized empty Git repository in /home/git/tmp.git/

4.配置ssh密钥

待续

你可能感兴趣的:(Linux)