Complete 20150806 Linux FAQs with Answers--How to install git on Linux.md

This commit is contained in:
Ping 2015-08-07 09:39:48 +08:00
parent 3797ce063d
commit 6323f7946f
2 changed files with 73 additions and 74 deletions

View File

@ -1,74 +0,0 @@
Translating by Ping
Linux FAQs with Answers--How to install git on Linux
================================================================================
> **Question:** I am trying to clone a project from a public Git repository, but I am getting "git: command not found" error. How can I install git on [insert your Linux distro]?
Git is a popular open-source version control system (VCS) originally developed for Linux environment. Contrary to other VCS tools like CVS or SVN, Git's revision control is considered "distributed" in a sense that your local Git working directory can function as a fully-working repository with complete history and version-tracking capabilities. In this model, each collaborator commits to his or her local repository (as opposed to always committing to a central repository), and optionally push to a centralized repository if need be. This brings in scalability and redundancy to the revision control system, which is a must in any kind of large-scale collaboration.
![](https://farm1.staticflickr.com/341/19433194168_c79d4570aa_b.jpg)
### Install Git with a Package Manager ###
Git is shipped with all major Linux distributions. Thus the easiest way to install Git is by using your Linux distro's package manager.
**Debian, Ubuntu, or Linux Mint**
$ sudo apt-get install git
**Fedora, CentOS or RHEL**
$ sudo yum install git
**Arch Linux**
$ sudo pacman -S git
**OpenSUSE**
$ sudo zypper install git
**Gentoo**
$ emerge --ask --verbose dev-vcs/git
### Install Git from the Source ###
If for whatever reason you want to built Git from the source, you can follow the instructions below.
**Install Dependencies**
Before building Git, first install dependencies.
**Debian, Ubuntu or Linux**
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x
**Fedora, CentOS or RHEL**
$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x
#### Compile Git from the Source ####
Download the latest release of Git from [https://github.com/git/git/releases][1]. Then build and install Git under /usr as follows.
Note that if you want to install it under a different directory (e.g., /opt), replace "--prefix=/usr" in configure command with something else.
$ cd git-x.x.x
$ make configure
$ ./configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/install-git-linux.html
作者:[Dan Nanni][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://ask.xmodulo.com/author/nanni
[1]:https://github.com/git/git/releases

View File

@ -0,0 +1,73 @@
Linux问答 -- 如何在Linux上安装Git
================================================================================
> **问题:** 我尝试从一个Git公共仓库克隆项目但出现了这样的错误提示“git: command not found”。 请问我该如何安装Git [注明一下是哪个Linux发行版]?
Git是一个流行的并且开源的版本控制系统VCS最初是为Linux环境开发的。跟CVS或者SVN这些版本控制系统不同的是Git的版本控制被认为是“分布式的”某种意义上git的本地工作目录可以作为一个功能完善的仓库来使用它具备完整的历史记录和版本追踪能力。在这种工作模型之下各个协作者将内容提交到他们的本地仓库中与之相对的会直接提交到核心仓库如果有必要再有选择性地推送到核心仓库。这就为Git这个版本管理系统带来了大型协作系统所必须的可扩展能力和冗余能力。
![](https://farm1.staticflickr.com/341/19433194168_c79d4570aa_b.jpg)
### 使用包管理器安装Git ###
Git已经被所有的主力Linux发行版所支持。所以安装它最简单的方法就是使用各个Linux发行版的包管理器。
**Debian, Ubuntu, 或 Linux Mint**
$ sudo apt-get install git
**Fedora, CentOS 或 RHEL**
$ sudo yum install git
**Arch Linux**
$ sudo pacman -S git
**OpenSUSE**
$ sudo zypper install git
**Gentoo**
$ emerge --ask --verbose dev-vcs/git
### 从源码安装Git ###
如果由于某些原因你希望从源码安装Git安装如下介绍操作。
**安装依赖包**
在构建Git之前先安装它的依赖包。
**Debian, Ubuntu 或 Linux Mint**
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x
**Fedora, CentOS 或 RHEL**
$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc xmlto docbook2x
#### 从源码编译Git ####
从 [https://github.com/git/git/releases][1] 下载最新版本的Git。然后在/usr下构建和安装。
注意,如果你打算安装到其他目录下(例如:/opt那就把"--prefix=/usr"这个配置命令使用其他路径替换掉。
$ cd git-x.x.x
$ make configure
$ ./configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/install-git-linux.html
作者:[Dan Nanni][a]
译者:[mr-ping](https://github.com/mr-ping)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://ask.xmodulo.com/author/nanni
[1]:https://github.com/git/git/releases