码迷,mamicode.com
首页 > 其他好文 > 详细

git(学习之二)编译安装

时间:2015-09-28 06:31:44      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:source   配置文件   协同   profile   




Git学习笔记
#####################################################
qq:1218761836
qq群:150181442
#####################################################

Git安装
1.    Yum安装git
yum install git –y
yum install -y  git-email git-gui gitk git-svn git-cvs    
其中git-svn  git-cvs 是支持svn  cvs协同工作时需要(可选择)
2.    开启git命令补齐功能(不过我测试不加这个也可以补齐)
. /etc/bash_completion.d/git 或者source /etc/bash_completion.d/git  
#运行此命令后即可在服务器上使用git的命令补齐功能。为了能够在终端开启时自动加载bash_completion脚本,需要在系统配置文件/etc/profile及本地配置文件~/.bashrc 中添加下面的内容。
#add  git
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-devel  openssl-devel zlib-devel  gcc*  \
perl perl-devel texinfo  xmlto   -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/  
[root@wx git-2.5.0]# 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

…………………………………………………………………………………………………………………………….
[root@wx-a git-2.5.0]# make configure
GIT_VERSION = 2.5.0
    GEN configure
[root@wx-a git-2.5.0]# ./configure –help # 查看安装的参数

[root@wx-a git-2.5.0]# ./configure --prefix=/application/git
[root@wx-a git-2.5.0]# make all doc info
[root@wx-a git-2.5.0]# make install install-doc install-html install-info
.................................................................................................................................
make[1]: Leaving directory `/usr/local/src/git-2.5.0/Documentation‘
make -C Documentation install-info
make[1]: Entering directory `/usr/local/src/git-2.5.0/Documentation‘
make[2]: Entering directory `/usr/local/src/git-2.5.0‘
make[2]: `GIT-VERSION-FILE‘ is up to date.
make[2]: 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[1]: Leaving directory `/usr/local/src/git-2.5.0/Documentation‘


man git 查看git命令的使用说明

[root@wx-a ~]# 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 [ARGS]

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[1] 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[2] 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[1]: *** [git-add.1] Error 127
make[1]: Leaving directory `/usr/local/src/git-1.7.12.3/Documentation‘
make: *** [install-doc] Error 2

依赖包的问题
yum install -y xmlto

错误二
/bin/sh: line 1: docbook2x-texi: command not found
make[1]: *** [user-manual.texi] Error 127
make[1]: Leaving directory `/usr/local/src/git-1.7.12.3/Documentation‘
make: *** [install-info] Error 2

git完整安装需要asciidoc,docbook2X
yum install -y openjade  texinfo  perl-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



本文出自 “小菜鸟” 博客,请务必保留此出处http://xiaocainiaox.blog.51cto.com/4484443/1698634

git(学习之二)编译安装

标签:source   配置文件   协同   profile   

原文地址:http://xiaocainiaox.blog.51cto.com/4484443/1698634

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!