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

Stella981
• 阅读 523

环境说明:

     OS:CentOS-6.5.mininal  (NULL)

GIT:git version 2.8.2

准备工作:

  • 安装 EPEL源

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

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

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

  • 时间校准

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

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

安装Git( 源代码安装

  Step 1: 安装所需的依赖包

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

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

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

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

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

  Step 3:核实GIT 版本

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

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

  Step 4:命令补全

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

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

    [root@lucia git-2.8.2]# sudo cat >> ~/.bashrc  <<EOF
    > if [ -f /etc/bash_completion.d/git-completion.bash ]; then
    > . /etc/bash_completion.d/git-completion.bash
    > fi
    > EOF
    [xiaolu@lucia git-2.8.2]$ su root
    [root@lucia git-2.8.2]# sudo cat >> /etc/profile <<EOF
    > if [ -f /etc/bash_completion.d/git-completion.bash ]; then
    > . /etc/bash_completion.d/git-completion.bash
    > fi
    > EOF
    

附1:中文支持

  • 相关说明:

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

  • UTF8字符集:

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

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

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

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

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

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

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

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

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

附2:相关问题

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

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

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

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

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

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

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

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

                                                       Lucia   2016/05

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

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

# 以这种格式 https://{username}:{password}@git.oschina.net写入隐藏文件.git-credentials
[xiaolu@lucia ~]$ echo https://{luciaxxx@163.com}:{xxxxxx}@git.oschina.net >> .git-credentials
[xiaolu@lucia ~]$ cat .git-credentials 
https://{luciaxxx@163.com}:{xxxxxx}@git.oschina.net

# 运行git配置命令
[xiaolu@lucia ~]$ git config --global credential.helper store
[xiaolu@lucia ~]$ cat .gitconfig 
[credential]
    helper = store

# 第一次拉取仓库时仍需要输入用户名及密码进行验证
[xiaolu@lucia ~]$ git clone https://git.oschina.net/lucia-moore/Auto-Install.git
Cloning into 'Auto-Install'...
Username for 'https://git.oschina.net': luciaxxx@163.com
Password for 'https://luciaxxx@163.com@git.oschina.net': 
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
Checking connectivity... done.

[xiaolu@lucia ~]$ ls
Auto-Install

#此时查看文件.git-credentials会多出一项,证明配置成功了
[xiaolu@lucia ~]$ cat .git-credentials 
https://luciaxxx%40163.com:xxxxxx@git.oschina.net
https://{luciaxxx@163.com}:{xxxxxx}@git.oschina.net

#此时 git pull 就不需要输入用户名和密码直接pull
[xiaolu@lucia ~]$ cd Auto-Install/
[xiaolu@lucia Auto-Install]$ git pull https://git.oschina.net/lucia-moore/Auto-Install.git
From https://git.oschina.net/lucia-moore/Auto-Install
 * branch            HEAD       -> FETCH_HEAD
Already up-to-date.
点赞
收藏
评论区
推荐文章
blmius blmius
2年前
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
Jacquelyn38 Jacquelyn38
2年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Wesley13 Wesley13
2年前
Java获得今日零时零分零秒的时间(Date型)
publicDatezeroTime()throwsParseException{    DatetimenewDate();    SimpleDateFormatsimpnewSimpleDateFormat("yyyyMMdd00:00:00");    SimpleDateFormatsimp2newS
Stella981 Stella981
2年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Wesley13 Wesley13
2年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
2年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
2年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Wesley13 Wesley13
2年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
4个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这