Git Installation and Configuration
Before using Git we need to install Git. Git is currently supported running on Linux / Unix, Solaris, Mac and Windows platforms.
Git each platform installation package download address: http://git-scm.com/downloads
Installation on Linux platform
Git work need to call curl, zlib, openssl, expat, libiconv library code, etc., so you need to install these tools rely on.
There yum on the system (such as Debian system) (such as Fedora) or apt-get have a system, you can use the following command to install:
Each Linux systems can easily install more using their package management tools installed:
Debian / Ubuntu
Debian / Ubuntu Git installation command:
$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \ libz-dev libssl-dev $ apt-get install git-core $ git --version git version 18.104.22.168
Centos / RedHat
If you are using Centos / RedHat installation command:
$ yum install curl-devel expat-devel gettext-devel \ openssl-devel zlib-devel $ yum -y install git-core $ git --version git version 1.7.1
Installed on the Windows platform
Install Git on Windows platforms as easily, a man named msysGit project provides installation package can go to the GitHub page to download the installation file and run the exe:
Download the installation package: http://msysgit.github.io/
After installation is complete, you can use the git command line tool (already comes with ssh client), and in addition to a graphical Git project management tool.
Find "Git" in the Start menu -> "Git Bash", Git command window will pop up, you can make Git operate in this window.
Installation on the Mac platform
Undoubtedly the easiest to install Git on a Mac platform using the graphical Git installation tool, download address is:
Installation interface is as follows:
Git provides a tool called git config, designed to configure or read the corresponding environment variable.
These environment variables to determine the specific Git work and behavior in all aspects. These variables can be stored in three different places:
/etc/gitconfigfile: the system for all users of general application configuration. If you use
--systemoption is to read and write this file.
~/.gitconfigfile: user profile directory apply only to that user. If you use
--globaloption is to read and write this file.
- Git directory of the current project configuration file (that is, the working directory
.git/configfile): This configuration is only valid for the current project. Each level configuration will cover the same configuration of the upper, so
.git/configin the configuration will overwrite
/etc/gitconfigthe variables of the same name.
On Windows systems, Git will find .gitconfig file the user's home directory. Directory Main directory that is specified by $ HOME variable, usually C: \ Documents and Settings \ $ USER.
Additionally, Git will try to find the / etc / gitconfig file, just to see what had Git installed in the directory, as the root directory to locate.
Configure personal user name and e-mail address:
$ git config --global user.name "w3big" $ git config --global user.email email@example.com
If the --global option, change the configuration file is located in that, after all of your project will use the default user information configured here under your user's home directory.
If you want to use a different name or e-mail on a particular project, as long as the option to remove --global reconfiguration, the new setting is stored in .git / config file in the current project.
Git set default text editor, the general may be Vi or Vim. If you have other preferences, such as Emacs, you can re-set ::
$ git config --global core.editor emacs
Difference analysis tool
There is also a more common is the use of what kind of difference analysis tool in resolving merge conflicts. For example, if you want to use vimdiff:
$ git config --global merge.tool vimdiff
Git will be appreciated output kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff merger tool.
Of course, you can also specify your own development tool, specifically how to do can be found in Chapter VII.
View configuration information
To check the existing configuration information, you can use the git config --list command:
$ git config --list http.postbuffer=2M user.name=w3big firstname.lastname@example.org
Sometimes see duplicate variable names, it shows that they come from different configuration files (such as / etc / gitconfig and ~ / .gitconfig), but in the end Git actually used the last one.
These configurations we can ~ / .gitconfig or / etc / gitconfig see, as follows:
Display as follows:
[http] postBuffer = 2M [user] name = w3big email = email@example.com
You can also have direct access to a set environment variables, as long as the specific name can be followed, like this:
$ git config user.name w3big