[Git] Cài đặt Git trên Ubuntu

Git-Logo-White

  • Ubuntu 10.04 x64
  • git v2.0.0

[Ref]

[1] http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
[2] https://progit.org/

 

[#1] Gỡ bỏ phiên bản cũ

[09:29 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ git --version
git version 1.7.0.4

[09:30 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ sudo apt-get remove git-core
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libdigest-sha1-perl cmake-data libvpx0 liberror-perl emacsen-common
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  git-core
0 upgraded, 0 newly installed, 1 to remove and 33 not upgraded.
After this operation, 12.7MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 158673 files and directories currently installed.)
Removing git-core ...
Processing triggers for man-db ...

[09:31 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ git --version
bash: /usr/bin/git: No such file or directory

 

[#2] Download source

 Download git-2.0.0.tar.gz @ https://www.kernel.org/pub/software/scm/git/

 

[#3] Cài thêm một số binary cần thiết

$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev autoconf asciidoc docbook2x

 

[#4] Giải nén source, biên dịch & cài đặt

[09:38 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ make configure
    GEN configure

[09:39 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ ./configure --prefix=/usr
configure: Setting lib to 'lib' (the default)
configure: Will try -pthread then -lpthread to enable POSIX Threads.
configure: CHECKS for site configuration
configure: CHECKS for programs
checking for cc... cc

[09:41 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ make all doc info
    * new build flags
    CC credential-store.o
    * new link flags
    CC abspath.o
    CC advice.o
    CC alias.o
    CC alloc.o
    CC archive.o
    CC archive-tar.o
...

[11:54 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ sudo make install install-doc install-html install-info
    GEN perl/PM.stamp
    SUBDIR gitweb
    SUBDIR ../
make[2]: `GIT-VERSION-FILE' is up to date.
    GEN git-instaweb
    SUBDIR git-gui
    SUBDIR gitk-git
    SUBDIR perl
    SUBDIR templates
install -d -m 755 '/usr/bin'
install -d -m 755 '/usr/libexec/git-core'
...
# install RelNotes/1.9.3.txt /usr/share/doc/git/RelNotes/1.9.3.txt
# install RelNotes/2.0.0.txt /usr/share/doc/git/RelNotes/2.0.0.txt
# install docbook-xsl.css /usr/share/doc/git/docbook-xsl.css
make[1]: Leaving directory `/home/datvtb/Downloads/git-2.0.0/Documentation'
make -C Documentation install-info
make[1]: Entering directory `/home/datvtb/Downloads/git-2.0.0/Documentation'
make[2]: Entering directory `/home/datvtb/Downloads/git-2.0.0'
make[2]: `GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory `/home/datvtb/Downloads/git-2.0.0'
install -d -m 755 /usr/share/info
install -m 644 git.info gitman.info /usr/share/info
if test -r /usr/share/info/dir; then \
	  install-info --info-dir=/usr/share/info git.info ;\
	  install-info --info-dir=/usr/share/info gitman.info ;\
	else \
	  echo "No directory found in /usr/share/info" >&2 ; \
	fi
This is not dpkg install-info anymore, but GNU install-info
See the man page for ginstall-info for command line arguments
This is not dpkg install-info anymore, but GNU install-info
See the man page for ginstall-info for command line arguments
make[1]: Leaving directory `/home/datvtb/Downloads/git-2.0.0/Documentation'

[11:58 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ git --version
git version 2.0.0

 

[#5] Test

[12:10 AM]datvtb@datvtb ~/temp/test
$ git clone https://github.com/git/git
Cloning into 'git'...
remote: Counting objects: 179890, done.
remote: Compressing objects: 100% (11/11), done.
Receiving objects:  15% (28034/179890), 9.87 MiB | 36.00 KiB/s

 

Một số lỗi có thể gặp

  •  Chưa cài autoconf
[09:37 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ make configure
GIT_VERSION = 2.0.0
    GEN configure
/bin/sh: autoconf: not found
make: *** [configure] Error 127

 

  • Chưa cài asciidoc
[09:41 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ make all doc info
    * new build flags
    CC credential-store.o
    * new link flags
    CC abspath.o
    CC advice.o
...
make[2]: `GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory `/home/datvtb/Downloads/git-2.0.0'
    ASCIIDOC git-add.html
/bin/sh: asciidoc: not found

 

  • Chưa cài docbook2x
[09:45 PM]datvtb@datvtb ~/Downloads/git-2.0.0
$ sudo apt-get install asciidoc
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libdigest-sha1-perl cmake-data libvpx0 liberror-perl emacsen-common
Use 'apt-get autoremove' to remove them.
...
make[2]: `GIT-VERSION-FILE' is up to date.
make[2]: Leaving directory `/home/datvtb/Downloads/git-2.0.0'
    DB2TEXI user-manual.texi
/bin/sh: docbook2x-texi: not found