CentOS Install git Source

前言

Git

同生活中的许多伟大事件一样,Git 诞生于一个极富纷争大举创新的年代。Linux 内核开源项目有着为数众广的参与者。绝大多数的 Linux 内核维护工作都花在了提交补丁和保存归档的繁琐事务上(1991-2002年间)。到 2002 年,整个项目组开始启用分布式版本控制系统 BitKeeper 来管理和维护代码。官方文档

到了 2005 年,开发 BitKeeper 的商业公司同 Linux 内核开源社区的合作关系结束,他们收回了免费使用 BitKeeper 的权力。这就迫使 Linux 开源社区(特别是 Linux 的缔造者 Linus Torvalds )不得不吸取教训,只有开发一套属于自己的版本控制系统才不至于重蹈覆辙。他们对新的系统制订了若干目标:

  • 速度
  • 简单的设计
  • 对非线性开发模式的强力支持(允许上千个并行开发的分支)
  • 完全分布式
  • 有能力高效管理类似 Linux 内核一样的超大规模项目(速度和数据量)

安装

git 源码安装。下载源码

1
# wget https://github.com/git/git/archive/v2.21.0.zip

解压缩

1
2
3
4
5
# tar zxvf v2.21.0.zip
# cd git-2.20.1

编译命令如下
# # make prefix=/usr/local/git all

如果遇到该错误

1
2
3
http.h:6:23: warning: curl/curl.h: No such file or directory
http.h:7:23: warning: curl/easy.h: No such file or directory
……
1
2
执行命令
# yum install -y curl curl-devel

重新执行编译命令

发现编译报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    CC http.o
CC http-walker.o
CC http-fetch.o
LINK git-http-fetch
CC http-push.o
http-push.c:22:19: warning: expat.h: No such file or directory
http-push.c:830: warning: type defaults to ‘int’ in declaration of ‘XML_Char’
http-push.c:830: error: expected ‘;’, ‘,’ or ‘)’ before ‘*’ token
http-push.c: In function ‘lock_remote’:
http-push.c:900: error: ‘XML_Parser’ undeclared (first use in this function)
http-push.c:900: error: (Each undeclared identifier is reported only once
http-push.c:900: error: for each function it appears in.)
http-push.c:900: error: expected ‘;’ before ‘parser’
http-push.c:907: warning: implicit declaration of function ‘XML_SetUserData’
http-push.c:907: error: ‘parser’ undeclared (first use in this function)
http-push.c:908: warning: implicit declaration of function ‘XML_SetElementHandler’
http-push.c:910: warning: implicit declaration of function ‘XML_SetCharacterDataHandler’
http-push.c:910: error: ‘xml_cdata’ undeclared (first use in this function)
http-push.c:911: warning: implicit declaration of function ‘XML_Parse’
http-push.c:916: warning: implicit declaration of function ‘XML_ErrorString’
http-push.c:917: warning: implicit declaration of function ‘XML_GetErrorCode’
http-push.c:920: warning: implicit declaration of function ‘XML_ParserFree’
http-push.c: In function ‘remote_ls’:
http-push.c:1154: error: ‘XML_Parser’ undeclared (first use in this function)
http-push.c:1154: error: expected ‘;’ before ‘parser’
http-push.c:1161: error: ‘parser’ undeclared (first use in this function)
http-push.c:1164: error: ‘xml_cdata’ undeclared (first use in this function)
http-push.c: In function ‘locking_available’:
http-push.c:1228: error: ‘XML_Parser’ undeclared (first use in this function)
http-push.c:1228: error: expected ‘;’ before ‘parser’
http-push.c:1235: error: ‘parser’ undeclared (first use in this function)
make: *** [http-push.o] Error 1

执行命令解决这个问题

1
# yum install -y expat-devel

再次重新执行编译命令

发现再次报错

1
2
3
4
5
6
7
GITGUI_VERSION = 0.21.GITGUI
* new locations or Tcl/Tk interpreter
GEN git-gui
INDEX lib/
* tclsh failed; using unoptimized loading
MSGFMT po/bg.msg make[1]: *** [po/bg.msg] Error 127
make: *** [all] Error 2

执行命令解决

1
# yum install -y tcl build-essential tk gettext

再次重新执行编译命令

git源码编译成功执行执行命令

1
# make prefix=/usr/local/git install

1
2
3
4
5
6
7
8
9
10
11
12
# cd /usr/local/git/
# ls
bin libexec share


# cd bin/
# ls
git git-cvsserver gitk git-receive-pack git-shell git-upload-archive git-upload-pack


# ./git --version
git version 2.20.1

安装完成。

-------------本文结束感谢您的阅读-------------

本文标题:CentOS Install git Source

文章作者:Wang Jiemin

发布时间:2019年03月25日 - 13:03

最后更新:2019年03月25日 - 13:03

原始链接:https://jiemin.wang/2019/03/25/git-install/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

0%