首页 > 系统 > Linux教程

linux安装git的方法步骤

admin Linux教程 2022-02-10 12:02:35 linux安装git"

1、简介

Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。

Git是一个开源的分布式版本控制系统,用以有效、高速的处理从很小到非常大的项目版本管理。

Git 是 Linus Torvalds 为了帮助管理 Linux 内核开发而开发的一个开放源码的版本控制软件

安装环境

阿里云ECS CentOS 7.4 64位

2、使用shell安装git

请将下载的shell与下面代码保存到同一目录

cnl_function.sh

#!/bin/bash
source ./cnl_function.sh

#function of installing git
install_git(){
  #download the compressed package
  cd /usr/local/src
  #if compressed package is empty then download
  [ -f git-2.2.1.tar.gz ] || wget https://www.kernel.org/pub/software/scm/git/git-2.2.1.tar.gz
  check_ok

  tar -zxf git-2.2.1.tar.gz
  check_ok

  [ -d /usr/local/git ] && mv /usr/local/git /usr/local/git_`date +%s`  
  cd git-2.2.1
  check_ok
  
  for p in expat-devel 
  do 
    myum $p
  done

  make prefix=/usr/local/git all
  make prefix=/usr/local/git install
  check_ok
  
  if ! grep '^git:' /etc/group
  then 
    groupadd git
  fi  
  
  if ! grep '^git:' /etc/passwd
  then
    useradd -m git -s /usr/local/git/bin/git-shell -g git
  fi  
  check_ok
  ln -s /usr/local/git/bin/git /usr/local/bin/git
  
  echo "git is installed finish."  
}

read -p "Enter (Y) to start installation git :" n
if [ $n == 'Y' ]
then 
  echo "Start installation==============================================================================================================================>"
  install_git
else 
  echo "Cancel the installation."
fi

如下图,我将上面代码保存位cnl_install_git.sh 

执行脚本,按提示输入即可

命令行执行

git --version

安装完成。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持潘少俊衡。

版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
本文地址:/jtjc/Linux/113626.html

留言与评论(共有 0 条评论)
   
验证码:

潘少俊衡

| 桂ICP备2023010378号-4

Powered By EmpireCMS

爱享小站

中德益农

谷姐神农

环亚肥料

使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

感谢潘少俊衡友情技术支持