Install Git on Linux

1. Package manager installation

  Git is easiest to install using your Linux distribution's package manager, and features such as command completion are automatically configured. But the installed Git might not be the latest version.

  •   Ubuntu 10.10 or newer , Debian (squeeze) or newer:
sudo aptitude install git
sudo aptitude install git-doc git-svn git-email git-gui gitk

  Ubuntu 10.04 (lucid) or older, Debian (lenny) or older:

sudo aptitude install git-core
sudo aptitude install git-doc git-svn git-email git-gui gitk

  Note: In older versions of Debian, the package git actually referred to GNU Interactive Tools, not Git as the version control system. Git as the version control system was in the package git-core.

 The git package contains most of the Git commands and is a must-installed package.

  The packages git-svn, git-email, git-gui, and gitk were originally part of the Git package, but because the packages git-svn, git-email, git-gui, and gitk were originally part of the Git package, but Because it has different package dependencies (such as more perl modules and tk, etc.), it is released as a separate package.

  The package git-doc contains Git documentation in HTML format, which can be optionally installed. If the Git package git-doc is installed, it contains Git's HTML format documentation, which can be optionally installed. If you have Git's HTML documentation installed, you can automatically open HTML help for the associated subcommand <sub-comman> in a web browser by executing the git help -w <sub-command> command.

  • RHEL、Fedora、CentOS:  
yum install git
yum install git-doc git-svn git-email git-gui gitk

  

2. Install from source

  Visit Git's official website: http://git-scm.com/. Download the Git source package. The installation process is as follows:

  1. Expand the source package and enter the corresponding directory.

tar -jxvf git-1.8.3.1.tar.bz2
cd git-1.8.3.1/

  2. The installation method is written in the INSTALL file, and the installation can be completed by referring to the instructions. The following command installs Git in /usr/local/bin.

make  prefix=/usr/local  all
sudo make prefix=/usr/local  install

  3. Install Git documentation (optional)

  The compiled documents are mainly in HTML format, which can be easily viewed through the git help -w <sub-command> command. In fact, even if you don't have Git documentation installed, you can use the man page to view Git help, using the commands git help <sub-command> or git <sub-command> --help.

  Compiling the documentation depends on asciidoc, so you need to install asciidoc first, and then compile the documentation. It takes a lot of time when compiling the documentation, be patient.

make prefix=/usr/local odc info
sudo make prefix=/usr/local  install-doc  install-html  install-info

  After the installation is complete, you can find the git command under the /usr/local/bin command.

 

3. Install from the Git repository

  If you clone the repository of a Git project locally, you can use the repository synchronization method to obtain the latest version of Git. In this way, when downloading different versions of Git source code, the incremental method is actually adopted, which saves time and space. Of course, the premise of using this method is that Git has been installed by other methods. The specific operation process is as follows.

  (1) Clone the repository of the Git project to the local.

git clone git://git.kernel.org/pub/scm/git/git.git
cd go

  (2) If the repository of a Git project has been cloned locally, update it directly in the workspace to obtain an updated version of Git.

git fetch

  (3) Perform cleanup work to avoid the impact of the legacy files of the previous compilation on the compilation. Note that the following will discard local changes to the Git code.

git clean -fdx
git reset --hard

  (4) View the milestones of Git and select the latest version to install  

git day

  (5) Check out this version of the code 

git checkout v.1.8.3.1

  (6) Execute the installation. For example, install to the /usr/local directory.  

make prefix=/usr/local all doc info
sudo make prefix=/usr/local install \
install-doc install-html install-info

  

 

 

  

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324890487&siteId=291194637