当前位置:   article > 正文

CentOS 7 安装 git 服务器

CentOS 7 安装 git 服务器

安装依赖库 gcc、zlib

[git@centos100 ~]$ sudo yum install gcc
[git@centos100 git-2.9.5]$ sudo yum install zlib-devel
  • 1
  • 2

安装 perl

  1. 下载 perl

    [git@centos100 git-2.9.5]$ curl -O https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz

  2. 解压 perl

    [git@centos100 ~]$ tar zxf perl-5.28.0.tar.gz

  3. 安装 perl

    [git@centos100 perl-5.28.0]$ ./Configure -des -Dprefix=/usr/local/perl-5.28.0
    [git@centos100 perl-5.28.0]$ make
    [git@centos100 perl-5.28.0]$ sudo make install

  4. perl 查看版本号

    [git@centos100 ~]$ perl -v
    This is perl 5, version 28, subversion 0 (v5.28.0) built for x86_64-linux
    Copyright 1987-2018, Larry Wall

下载 git

[git@centos100 ~]$ curl -O https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
  • 1

git 安装

[git@centos100 git-2.9.5]$ tar zxf git-2.9.5.tar.gz
[git@centos100 git-2.9.5]$ cd git-2.9.5
[git@centos100 git-2.9.5]$ ./configure --prefix=/usr/local/git-2.9.5
[git@centos100 git-2.9.5]$ make
[git@centos100 git-2.9.5]$ sudo make install
  • 1
  • 2
  • 3
  • 4
  • 5

添加到环境变量:

[git@centos100 git-2.9.5]$ sudo vi /etc/profile
  • 1

export GIT_HOME=/usr/local/git-2.9.5
export PATH=$PATH:$GIT_HOME/bin

使环境变量生效

[git@centos100 git-2.9.5]$ source /etc/profile
  • 1

添加软连接

[git@centos100 bin]$ sudo ln -s /usr/local/git-2.9.5/bin/git-upload-pack /usr/bin/git-upload-pack
[git@centos100 bin]$ sudo ln -s /usr/local/git-2.9.5/bin/git-receive-pack /usr/bin/git-receive-pack
  • 1
  • 2

服务器创建空仓库

[git@centos100 ~]$ mkdir repository/my_project
[git@centos100 my_project]$ git init --bare my_project.git
  • 1
  • 2

客户端克隆代码

$ git clone git@192.168.158.100:/home/git/repository/my_project/my_project.git
Cloning into 'my_project'...
git@192.168.158.100's password:
warning: You appear to have cloned an empty repository.
  • 1
  • 2
  • 3
  • 4

安装完毕。。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/661063
推荐阅读
相关标签
  

闽ICP备14008679号