Git是一個開源的分佈式版本控制系統由Linus Torvalds,Linux的創造者。 它功能簡單的分支和合並,爲單個項目管理多個遠程倉庫,和真正的分佈式開發。html
儘管git是美好的在管理大型、複雜的項目也許成百上千的貢獻者,它還能夠爲小型項目工做很是好與一我的或一個小團隊。 這種靈活性使它實現版本的一個很好的選擇,爲任何規模的軟件項目源代碼控制。linux
在本文中,咱們將介紹如何安裝CentOS 6.4服務器使用git 百勝
CentOS包管理器。 咱們將展現如何從源代碼安裝git,以防你想從最新的改進中獲益。git
和大多數Linux發行版同樣,git是能夠從CentOS的默認存儲庫。 咱們能夠安裝包維護者的最新版本:github
sudo yum install git
你要確認安裝「y」型。 後來,git將安裝並可使用了。服務器
若是你想要最新版本的git,最好下載最新版本從源代碼和編譯。編輯器
CentOS的版本庫1.7.1上在撰寫本文時,最新版本的git 1.8.4,這是一個很大的不一樣之處。分佈式
首先,咱們須要下載編譯工具CentOS使用如下命令:ide
sudo yum groupinstall "Development Tools"
這將安裝製造工具和編譯器須要將源代碼轉換成二進制可執行文件。工具
一旦完成,咱們將須要安裝一些額外的依賴,git須要創建或運行:this
sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel
一旦這些安裝,您能夠得到最新版本的代碼託管在git github.com :
cd ~ wget -O git.zip https://github.com/git/git/archive/master.zip
解壓存檔和變動到項目目錄:
unzip git.zip cd git-master
咱們能夠圖方案,構建可執行文件和文檔,而後安裝它下面的命令:
make configure ./configure --prefix=/usr/local make all doc sudo make install install-doc install-html
更新git在稍後的日期,你可使用git ! 克隆git存儲庫在github上到一個新目錄,而後構建和安裝它,像之前同樣:
git clone git://github.com/git/git
與git提交更改時,它嵌入您的姓名和電子郵件地址提交消息爲了輕鬆地跟蹤變化。
若是咱們不配置這些信息本身,git可能試圖猜想這些值(多是錯誤的)經過使用您的Linux用戶名和主機名。
給git您但願使用這些參數值與這些命令:
git config --global user.name "Your Name Here" git config --global user.email "your_email@example.com"
配置更改將存儲在一個文件在您的主目錄。 你能夠看到他們一個普通的文本編輯器:
nano ~/.gitconfig[user] name = Your Name Here email = your_email@example.com
您還能夠查看這些信息經過查詢git當前配置設置:
git config --listuser.name=Your Name Here user.email=your_email@example.com
如前所述,若是您忘了設置這些步驟,git可能試圖填補這些值自動:
[master 0d9d21d] initial project version Committer: root Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly: git config --global user.name "Your Name" git config --global user.email you@example.com After doing this, you may fix the identity used for this commit with: git commit --amend --reset-author
根據您的git版本,它徹底可能會失敗:
git commit
*** Please tell me who you are. Run git config --global user.email "you@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident name (for ) not allowed
如您所見,git是很好的告訴你你應該作什麼。