Git Concept
Git is actually a distributed version control system, opposite to centralized version control systems such as CVS and subversion. It has the following features:
• Fast
• Simple Design
• Strong support for non-linear development models (Thousands of parallel development branches allowed)
• Completely distributed
• Ability to efficiently manage ultra-large scale projects (speed and data volume) similar to the Linux Kernel)
Install git
1. Install from source code
If conditions permit, installation from source code has many advantages, at least the latest version can be installed. Each version of Git
They are constantly trying to improve the user experience, so it is better to compile and install the latest version by yourself through the source code.
Some Linux installation packages are not updated in time, unless you are using the latest distro or
Backports, which is the best choice for source code installation.
Git needs to call the code of libraries such as curl, zlib, OpenSSL, expat, and libiconv. Therefore, install these dependency tools first. If you have a yum system (such as fedora) or an apt-Get system (such as a Debian system), run the following command to install it:
$ Yum install curl-devel expat-devel gettext-devel \
OpenSSL-devel zlib-devel
$ Apt-Get install curl-devel expat-devel gettext-devel \
OpenSSL-devel zlib-devel
Then, download the latest source code from the following git official site:
Http://git-scm.com/download
Then compile and install:
$ Tar-zxf git-1.6.0.5.tar.gz
$ Git-1.6.0.5 CD
$ Make prefix =/usr/local all
$ Sudo make prefix =/usr/local install
Now you can run the GIT command to clone the GIT project repository to a local location so that it can be updated at any time in the future:
$ Git clone git: // git.kernel.org/pub/scm/git/git.git
2. Install
To install the pre-compiled git binary installation package on Linux, you can directly use the package management tool provided by the system. Install with Yum on fedora:
$ Yum install Git-core
You can use apt-get to install Debian systems such as Ubuntu:
$ Apt-Get instal Git-core
3. install on Mac
There are two ways to install git on Mac. The easiest option is to use a graphical git Installation tool.
In:
Http://code.google.com/p/git-osx-installer
The other is installed via macports (http://www.macports.org. If macports has been installed,
Run the following command to install git:
$ Sudo port install Git-Core + SVN + Doc + bash_completion + gitweb
In this way, you do not need to install the dependent libraries by yourself. macports will help you solve these troubles.
4. install on Windows
Installing git on Windows is equally easy. A project called msysgit provides the installation package, which can be
Download the Installation File (.exe) on the Google Code Page ):
Http://code.google.com/p/msysgit
After the installation is complete, you can use the GIT tool of the command line (which already comes with the SSH client). In addition
A graphical git project management tool.
Configuration before the first running of Git
Generally, in the new system, we need to configure our git work environment first. The configuration only needs to be performed once, and the current configuration will be used in future upgrades. Of course, if necessary, you can use the same command to modify the existing configurations at any time.
.
Git provides a tool called git config.
Call this command by adding a name to git .), It is used to configure or read the corresponding work environment variables. While Zheng
These environment variables determine how git works and acts in each step. These variables can be stored in
There are three differences:
•/Etc/gitconfig file: the configuration that is applicable to all users in the system. If you use git config
Use the -- System option to read and write the file.
•~ /. Gitconfig file: the configuration file in the user directory only applies to this user. If you use git config
Use the -- global option to read and write the file.
• Configuration file in the GIT directory of the current project (that is, the. Git/config file in the working directory ):
The configuration in is only valid for the current project. The configuration at each level overwrites the same configuration at the upper layer.
The configuration in. Git/config overwrites the variable with the same name in/etc/gitconfig.
On Windows, git looks for the. gitconfig file in the user's home directory. The main directory is the directory specified by the $ home variable, which is generally c: \ Documents ents and Settings \ $ user. In addition, git will try to find the/etc/gitconfig file, just to check the directory where git was originally installed and locate it as the root directory.
1. User Information
The first configuration is your personal user name and email address. These two configurations are very important.
These two information will be referenced at the time of delivery, indicating who submitted the update, so the updated content will be permanently included in the history
Recording:
$ Git config -- global user. Name "John Doe"
$ Git config -- global user. Email [email protected]
If the -- global option is used, the changed configuration file is located in the home directory of your user.
All projects use the user information configured here by default. If you want to use another name or
By email, you only need to remove the -- global option and reconfigure it. The new settings are saved in. Git/config of the current project.
File.
2. Text Editor
Next, set the default text editor. Git automatically calls an external text editor when you enter some additional messages. The Default Editor specified by the operating system is used by default, which may be
VI or vim. If you have other preferences, such as Emacs, You can reset them:
$ Git config -- global core. Editor Emacs
3. Difference Analysis Tools
Another commonly used difference analysis tool is used to solve the merge conflicts. For example, to use vimdiff
Statement:
$ Git config -- Global merge. Tool vimdiff
Git can understand kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge,
And opendiff.
4. View configuration information
To check the existing configuration information, run the GIT config -- LIST command:
$ Git config -- list
User. Name = Scott Chacon
[Email protected]
Color. Status = auto
Color. Branch = auto
Color. Interactive = auto
Color. Diff = auto
...
Sometimes we can see repeated variable names, which means they come from different configuration files (such as/etc/gitconfig
And ~ /. Gitconfig), but the final git actually uses the last one.
You can also directly check the setting of an environment variable, as long as the specific name is followed, like this:
$ Git config user. Name
Scott Chacon
6. Get help
If you want to know how to use git's various tools, you can read their help in three ways:
$ Git help <verb>
$ Git <verb> -- Help
$ Man Git-<verb>
For example, to learn how to use the config command, run:
$ Git help config
We can view the help information at any time without connecting to the Internet. However, if you think it is not enough, you can
# Git or # GitHub channel on the frenode IRC server (irc.freenode.net) for help from others. This
There are always hundreds of people on the two channels, most of which have a wealth of git knowledge and are helpful.