git(学习之二)编译安装
Git学习笔记#####################################################
qq:1218761836
qq群:150181442
#####################################################
Git安装
1. Yum安装git
yum install git –y
yum install -ygit-email git-gui gitk git-svn git-cvs
其中git-svngit-cvs 是支持svncvs协同工作时需要(可选择)
2. 开启git命令补齐功能(不过我测试不加这个也可以补齐)
. /etc/bash_completion.d/git 或者source /etc/bash_completion.d/git
#运行此命令后即可在服务器上使用git的命令补齐功能。为了能够在终端开启时自动加载bash_completion脚本,需要在系统配置文件/etc/profile及本地配置文件~/.bashrc 中添加下面的内容。
#addgit
if [ -f /etc/bash_completion.d/git ]; then
. /etc/bash_completion.d/git
fi
当然这里/etc/bash_completion.d/git的git脚本也可以复制源文件替换,
cp /usr/share/doc/git-1.7.1/contrib/completion/git-completion.bash /etc/bash_completion.d/
然后把文件中涉及到的git替换成git-completion.bash即可
参考: http://git-scm.com/download/linux
编译安装
编译安装需要安装一些git需要的库
yum install curl-devel expat-devel gettext-developenssl-devel zlib-develgcc*\
perl perl-devel texinfoxmlto -y
为了能够添加更多格式的文档(如 doc,html,info) 需要安装所依赖的包
yum install asciidoc xmlto -y
docbook2x 这个库需要额外安装
wget http://centos.karan.org/el5/extras/testing/i386/RPMS/docbook2X-0.8.8-1.el5.kb.i386.rpm
rpm -ivh docbook2X-0.8.8-1.el5.kb.i386.rpm –nodeps
cd /usr/bin/
ln -s db2x_docbook2texi docbook2x-texi
ll docbook2x-texi
获取源码包:
https://www.kernel.org/pub/software/scm/git/
https://github.com/git/git/releases
通常在 GitHub 上的是最新版本,但 kernel.org 上包含有文件下载签名,如果你想验证下载正确性的话会用到。
wget https://www.kernel.org/pub/software/scm/git/git-2.5.0.tar.gz
tar xvf git-2.5.0.tar.gz -C /usr/local/src/
# less INSTALL
Git installation
Normally you can just do "make" followed by "make install", and that
will install the git programs in your own ~/bin/ directory.If you want
to do a global install, you can do
$ make prefix=/usr all doc info ;# as yourself
# make prefix=/usr install install-doc install-html install-info ;# as root
(or prefix=/usr/local, of course).Just like any program suite
that uses $prefix, the built results have some paths encoded,
which are derived from $prefix, so "make all; make prefix=/usr
install" would not work.
The beginning of the Makefile documents many variables that affect the way
git is built.You can override them either from the command line, or in a
config.mak file.
Alternatively you can use autoconf generated ./configure script to
set up install paths (via config.mak.autogen), so you can write instead
$ make configure ;# as yourself
$ ./configure --prefix=/usr ;# as yourself
$ make all doc ;# as yourself
# make install install-doc install-html;# as root
…………………………………………………………………………………………………………………………….
# make configure
GIT_VERSION = 2.5.0
GEN configure
# ./configure –help # 查看安装的参数
# ./configure --prefix=/application/git
# make all doc info
# make install install-doc install-html install-info
.................................................................................................................................
make: Leaving directory `/usr/local/src/git-2.5.0/Documentation'
make -C Documentation install-info
make: Entering directory `/usr/local/src/git-2.5.0/Documentation'
make: Entering directory `/usr/local/src/git-2.5.0'
make: `GIT-VERSION-FILE' is up to date.
make: Leaving directory `/usr/local/src/git-2.5.0'
install -d -m 755 /application/git/share/info
install -m 644 git.info gitman.info /application/git/share/info
if test -r /application/git/share/info/dir; then \
install-info --info-dir=/application/git/share/info git.info ;\
install-info --info-dir=/application/git/share/info gitman.info ;\
else \
echo "No directory found in /application/git/share/info" >&2 ; \
fi
No directory found in /application/git/share/info
make: Leaving directory `/usr/local/src/git-2.5.0/Documentation'
man git 查看git命令的使用说明
# man git
GIT(1) Git Manual GIT(1)
NAME
git - the stupid content tracker
SYNOPSIS
git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
[-p|--paginate|--no-pager] [--no-replace-objects]
[--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
[--help] COMMAND
DESCRIPTION
Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both
high-level operations and full access to internals.
See gittutorial(7) to get started, then see Everyday Git for a useful minimum set of commands, and "man
git-commandname" for documentation of each command. CVS users may also want to read gitcvs-migration(7). See the Git
User’s Manual for a more in-depth introduction.
The COMMAND is either a name of a Git command (see below) or an alias as defined in the configuration file (see git-
config(1)).
Formatted and hyperlinked version of the latest git documentation can be viewed at
http://www.kernel.org/pub/software/scm/git/docs/. #man git的在线说明文档
......................................................................................................................................................................
备注:编译的时候可能会遇到错误,如果遇到以下故障
make的时候出错大都和依赖包有问题,如果安装的了相应的依赖包,编译起来很方便
错误一
/bin/sh: line 1: xmlto: command not found
make: *** Error 127
make: Leaving directory `/usr/local/src/git-1.7.12.3/Documentation'
make: *** Error 2
依赖包的问题
yum install -y xmlto
错误二
/bin/sh: line 1: docbook2x-texi: command not found
make: *** Error 127
make: Leaving directory `/usr/local/src/git-1.7.12.3/Documentation'
make: *** Error 2
git完整安装需要asciidoc,docbook2X
yum install -y openjadetexinfoperl-XML-SAX
cd /usr/local/src
wget http://centos.karan.org/el5/extras/testing/i386/RPMS/docbook2X-0.8.8-1.el5.kb.i386.rpm
rpm -ivh docbook2X-0.8.8-1.el5.kb.i386.rpm --nodeps
cd /usr/bin
ln -s db2x_docbook2texi docbook2x-texi
页:
[1]