Before you start using Git, you need to install it on your computer. Even if it is already installed, it is best to upgrade it to the latest version.
You can install through the package or other installer, or download the source code to compile the installation.
One, git installation
1. Installing on Linux
We can install using the Basic Package management tool included with the release version, and if Fedora is based, we can use
$sudo yum install git
If based on Debian, we can try Apt-get
$ sudo apt-get install git
The Git official website has installation steps on a variety of Unix-style systems, URL: http://git-scm.com/download/linux
2. Installing on Windows
There are several installation methods for installing Git on Windows.
A. Official version can be downloaded from Git's official website: Http://git-scm.com/download/win. Select the corresponding system version
B. Another easy way is to install GitHub for Windows, which contains both graphical and command-line versions of Git.
Website: http://windows.github.com
3. Install from source
If you want to install Git from the source, you need to install git-dependent libraries: curl, zlib, OpenSSL, expat, and Libiconv.
If you have Yum (such as Fedora) or apt-get (such as a Debian-based system) on your system, you can use one of the following commands
To install a minimized dependency package to compile and install Git's binaries:
$ sudo yum install curl-devel expat-devel gettext-devel \
openssl-devel zlib-devel
$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
libz-dev libssl-dev
In order to be able to add more formats to a document (such as doc, HTML, info), you need to install the following dependency packages:
$ sudo yum install asciidoc xmlto docbook2x
$
sudo apt-get install asciidoc xmlto docbook2x
When you install all the necessary dependencies, you can continue to get the latest released version of the TAR package from several places.
You can get it from the kernel.org website at Https://www.kernel.org/pub/software/scm/git,
or from the image on the GitHub website, the URL is https://github.com/git/git/releases.
This is usually the latest version on GitHub, but the kernel.org contains a file download signature, which is used if you want to verify that the download is correct.
Next, compile and install:
$ tar -zxf git-2.0.0.tar.gz
$ cd git-2.0.0
$ make configure
$ ./configure --prefix=/usr
$ make all doc info
$ sudo make install install-doc install-html install-info
When you are finished, you can use the command to upgrade
$git clone git://git.kernel.org/pub/scm/git/git.git
Second, first run git pre-configuration
Now that you've installed Git on your system, you'll want to do a few things to customize your git environment. Only one configuration is required on each computer,
The configuration information is preserved when the program is upgraded. You can modify them again at any time by running commands.
1. Setting up user Information
$ git config--global user.name yourname
$ git config--global user.email youremail
Again, if you use the --global
option, the command only needs to run once, because git will use that information whenever you do anything on that system.
When you want to use a different user name and email address for a particular project, you can configure it by running a command with no options in that project directory --global
.
2. Check configuration information
$ git config--list
As shown below,
We can also check a configuration by entering git config <key>
git start--git installation and first run git pre-configuration