Linux源代码安装Git及其他附录

环境说明:

     OS:CentOS-6.5.mininal  (NULL)

GIT:git version 2.8.2

准备工作:

  • 安装 EPEL源

    1[root@lucia ~]# su xiaolu 2[xiaolu@lucia root]$ cd /etc/yum.repos.d/ 3[xiaolu@lucia yum.repos.d]$ sudo yum -y install wget 4[xiaolu@lucia yum.repos.d]$ sudo mv CentOS-Base.repo CentOS-Base.repo.bak 5[xiaolu@lucia yum.repos.d]$ sudo wget -O CentOS-Base.repo https://lug.ustc.edu.cn/wiki/_export/code/mirrors/help/centos?codeblock=2   6                            # wget -O  --output-document=FILE  指定下载目录和文件名 7[xiaolu@lucia yum.repos.d]$ yum makecache

         根据CentOS的版本下载不同的镜像   (  使用的是国内的EPEL源-科大源)         

         附-科大源:https://lug.ustc.edu.cn/wiki/mirrors/help/centos

  • 时间校准

    1[xiaolu@lucia yum.repos.d]$ cd /tmp 2[xiaolu@lucia tmp]$ sudo yum -y install ntpdate.x86_64 3[xiaolu@lucia tmp]$ sudo ntpdate 0.pool.ntp.org 4 1 Apr 16:40:49 ntpdate[7329]: no server suitable for synchronization found 5--------------------------------------------------------------------------------- 6[xiaolu@lucia tmp]$ sudo yum -y install rdate.x86_64 7[xiaolu@lucia tmp]$ sudo rdate -s time.nist.gov 8[xiaolu@lucia tmp]$ date 9Sun May  1 23:17:19 CST 2016

            注:ntpdate校准报错选择rdate(很可能是防火墙封锁了udp的123端口, 如果关闭的防火墙问题依旧, 很可能是上层路由的设置有问题, 如果这种情况, 我们就只能通过tcp来更新时间)

安装Git( 源代码安装

  Step 1: 安装所需的依赖包

  •  源代码编译GIT之前,确保系统安装了所需的包或者通过以下命令来安装它

    1[xiaolu@lucia tmp]$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker package -y 2[xiaolu@lucia tmp]$ sudo yum -y install gcc  (下载 编译器 )

‍‍  Step 2:下载并编译GIT源代码 ‍‍

  •    从 git-scm 下载最新Git源代码或者简单的使用以下载命令下载Git 2.8.2

    1[xiaolu@lucia tmp]$ sudo wget -c https://www.kernel.org/pub/software/scm/git/git-2.8.2.tar.gz 2[xiaolu@lucia tmp]$ tar -zxvf git-2.8.2.tar.gz  3[xiaolu@lucia tmp]$ cd git-2.8.2 4[xiaolu@lucia git-2.8.2]$ make prefix=/usr/local/git all 5[xiaolu@lucia git-2.8.2]$ sudo make prefix=/usr/local/git install 6[xiaolu@lucia git-2.8.2]$ su root 7[root@lucia git-2.8.2]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc   # 设置环境变量 8[root@lucia git-2.8.2]# source /etc/bashrc

  Step 3:核实GIT 版本

  •   完成以上步骤后,使用以下命令检查GIT版本

    1[xiaolu@lucia git-2.8.2]$ git --version 2git version 2.8.2

  Step 4:命令补全

  •   Linux的shell环境通过bash-completion软件包提供命令补齐功能,在录入命令参数时按一次或两次TAB键可实现参数的自动补齐或提示

    1[xiaolu@lucia git-2.8.2]$ sudo cp contrib/completion/git-completion.bash /etc/bash_completion.d/    2                          #将Git源码包中的命令补全脚本肤质到bash-completion对应的目录中 3                           4[xiaolu@lucia git-2.8.2]. /etc/bash_completion.d/git-completion.bash 5                          #重新加载自动补齐脚本,使之在当前的shell中生效
  • 为了能够在终端开启时自动加载脚本,需要修改/etc/profile文件和~/.bashrc文件

    1[root@lucia git-2.8.2]# sudo cat >> ~/.bashrc  <<EOF 2> if [ -/etc/bash_completion.d/git-completion.bash ]; then 3> . /etc/bash_completion.d/git-completion.bash 4> fi 5> EOF 6[xiaolu@lucia git-2.8.2]$ su root 7[root@lucia git-2.8.2]# sudo cat >> /etc/profile <<EOF 8> if [ -/etc/bash_completion.d/git-completion.bash ]; then 9> . /etc/bash_completion.d/git-completion.bash 10> fi 11> EOF

附1:中文支持

  • 相关说明:

       ‍ GIT可以在提交说明中使用中文,但是需要对Git进行配置但对于用中文来命名文件、目录和引用,前提是使用UTF-8 字符集的环境下‍

  • UTF8字符集:

         1、在提交时,可以在提交说明中输入中文

         2、显示提交历史,能够正常显示提交说明中的中文字符

         3、可以添加名称为中文的文件,并可以在同样使用UTF-8字符集的Linux环境中克隆和检出

         4、可以创建带有中文字符的里程碑名称

        BUT!!!

  ❀   在默认设置下,中文文件名在工作区状态输出查看历史更改概要,以及在补丁文件中,文件名中的中文不能正确的显示,而是显示为八进制的字符编码,如下

1[xiaolu@lucia rs-project]$ git status -s 2?? "\346\265\213\350\257\225.txt" 3[xiaolu@lucia rs-project]$ printf "\346\265\213\350\257\225.txt\n" 4测试.txt

❀  **解决方法:**通过将Git配置变量 core.quotepath 设置为 false

1[xiaolu@lucia rs-project]$ git config --global core.quotepath false[xiaolu@lucia rs-project]2[xiaolu@lucia rs-project]$ git status -s 3?? 测试.txt

附2:相关问题

 make prefix=/usr/local/git all 报错

目前我碰到的报错有两种:

  1. 时间没有校准(看见 in the future 就是时间没有校准,校准后重新make)

    1ake[1]: Warning: File `Makefile' has modification time 2.5e+06 s in the future 2/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/share/locale' 3Writing perl.mak for Git 4make[1]: warning:  Clock skew detected.  Your build may be incomplete. 5    GEN git-add--interactive 6make[1]: Warning: File `Makefile' has modification time 2.5e+06 s in the future 7Writing perl.mak for Git 8make[2]: Warning: File `Makefile.PL' has modification time 2.5e+06 s in the future 9Writing perl.mak for Git 10make[2]: *** [perl.mak] Error 1 11make[1]: *** [instlibdir] Error 2 12make: *** [git-add--interactive] Error 2

   2. 第二种报依赖包错误,导致make失败

      本文OS是纯净版,实际上真正OS环境下许多依赖包已经安装,且通过yum仓库安装的版本都较老,换yum源后将提示的相关依赖包卸载(rpm -e),然后重新yum安装一下

#-------------------------------------------------------------------------------------------------------------------#

                                                        

                                                       Lucia   2016/05

#-------------------------------------------------------------------------------------------------------------------#

附3:记住GIT账户和密码(2016/09新增)

1# 以这种格式 https://{username}:{password}@git.oschina.net写入隐藏文件.git-credentials 2[xiaolu@lucia ~]$ echo https://{luciaxxx@163.com}:{xxxxxx}@git.oschina.net >> .git-credentials 3[xiaolu@lucia ~]$ cat .git-credentials 4https://{luciaxxx@163.com}:{xxxxxx}@git.oschina.net 5 6# 运行git配置命令 7[xiaolu@lucia ~]$ git config --global credential.helper store 8[xiaolu@lucia ~]$ cat .gitconfig 9[credential] 10 helper = store 11 12# 第一次拉取仓库时仍需要输入用户名及密码进行验证 13[xiaolu@lucia ~]$ git clone https://git.oschina.net/lucia-moore/Auto-Install.git 14Cloning into 'Auto-Install'... 15Username for 'https://git.oschina.net': luciaxxx@163.com 16Password for 'https://luciaxxx@163.com@git.oschina.net': 17remote: Counting objects: 3, done. 18remote: Total 3 (delta 0), reused 0 (delta 0) 19Unpacking objects: 100% (3/3), done. 20Checking connectivity... done. 21 22[xiaolu@lucia ~]$ ls 23Auto-Install 24 25#此时查看文件.git-credentials会多出一项,证明配置成功了 26[xiaolu@lucia ~]$ cat .git-credentials 27https://luciaxxx%40163.com:xxxxxx@git.oschina.net 28https://{luciaxxx@163.com}:{xxxxxx}@git.oschina.net 29 30#此时 git pull 就不需要输入用户名和密码直接pull 31[xiaolu@lucia ~]$ cd Auto-Install/ 32[xiaolu@lucia Auto-Install]$ git pull https://git.oschina.net/lucia-moore/Auto-Install.git 33From https://git.oschina.net/lucia-moore/Auto-Install 34 * branch HEAD -> FETCH_HEAD 35Already up-to-date.
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

Linux源代码安装Git及其他附录 - HelloWorld