版權聲明:本文為部落客chszs的原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/chszs/article/details/48196657
在Ubuntu搭建Git
作者:chszs,版權所有,未經同意,不得轉載。部落客首頁: http://blog.csdn.net/chszs
Git是一個開源的分布式版本控制系統,它在全球範圍内得到廣泛的使用。網際網路上還有像GitHub這樣的網站提供了免費的Git服務,很多流行的開源項目都使用了Git來托管項目,比如Perl、Ruby on Rails、Linux核心項目等。
在Ubuntu系統上安裝Git的最佳方式是使用Ubuntu軟體倉庫提供的軟體包,這些軟體包都是經過了充分測試的,已經完成了預編譯,安裝或解除安裝都非常友善。
下面我們将線上更新伺服器上的軟體倉庫索引,保證安裝的Git伺服器是比較新的穩定版。
1、更新系統并更新庫索引
# apt-get update
# apt-get upgrade
2、安裝Git服務
完成了更新操作後,就可以開始安裝Git服務了。
# apt-get install git-core
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
git git-man liberror-perl
Suggested packages:
git-daemon-run git-daemon-sysvinit git-doc git-el git-arch
git-cvs git-svn git-email git-gui gitk gitweb
The following NEW packages will be installed:
git git-core git-man liberror-perl
0 upgraded, 4 newly installed, 0 to remove and 100 not upgraded.
Need to get 6,752 kB of archives.
After this operation, 15.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://cn.archive.ubuntu.com/ubuntu/ precise/main liberror-perl all 0.17-1 [23.8 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu/ precise-updates/main git-man all 1:1.7.9.5-1ubuntu0.1 [631 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu/ precise-updates/main git amd64 1:1.7.9.5-1ubuntu0.1 [6,097 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu/ precise-updates/main git-core all 1:1.7.9.5-1ubuntu0.1 [1,380 B]
Fetched 6,752 kB in 1s (3,712 kB/s)
Selecting previously unselected package liberror-perl.
(Reading database ... 51734 files and directories currently installed.)
Unpacking liberror-perl (from .../liberror-perl_0.17-1_all.deb) ...
Selecting previously unselected package git-man.
Unpacking git-man (from .../git-man_1%3a1.7.9.5-1ubuntu0.1_all.deb) ...
Selecting previously unselected package git.
Unpacking git (from .../git_1%3a1.7.9.5-1ubuntu0.1_amd64.deb) ...
Selecting previously unselected package git-core.
Unpacking git-core (from .../git-core_1%3a1.7.9.5-1ubuntu0.1_all.deb) ...
Processing triggers for man-db ...
Setting up liberror-perl (0.17-1) ...
Setting up git-man (1:1.7.9.5-1ubuntu0.1) ...
Setting up git (1:1.7.9.5-1ubuntu0.1) ...
Setting up git-core (1:1.7.9.5-1ubuntu0.1) ...
3、基本的配置
一旦完成以上安裝過程,就該進行Git服務的配置。最基本的配置是這樣的:
# git config --global user.name "chszs"
# git config --global user.email [email protected]
可以根據自己的實際,替換使用者名和密碼。