Git installation configuration

Git needs to be installed before using Git. Git currently supports running on Linux/Unix, Solaris, Mac and Windows platforms.

The download address of Git installation package for each platform is: http://git-scm.com/downloads


Installation on Linux platform

The work of Git needs to call the code of libraries such as curl, zlib, openssl, expat, libiconv, etc., so you need to install these dependent tools first.

If the system used is Centos/RedHat, the installation command is:

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
$ yum -y install git-core
$ git --version
git version 1.8.3.1

Git configuration

Git provides a tool called git config, which is specially used to configure or read the corresponding working environment variables.

These environment variables determine how Git works and behaves in various ways. These variables can be stored in three different places:

/etc/gitconfig Files: Configurations that are common to all users on the system. If  the option git config is used  --system , it is this file that is read and written.

~/.gitconfig File: The configuration files in the user directory are only applicable to this user. If  the option git config is used  --global , it is this file that is read and written.

Configuration files in the current project's Git directory (that is,  .git/config files in the working directory): The configuration here is only valid for the current project.

The configuration of each level will override the same configuration of the upper layer, so  .git/config the configuration in will override  /etc/gitconfig the variable of the same name in the.

In addition, Git will also try to find the /etc/gitconfig file, just look at the directory where Git was installed, and use it as the root directory to locate.

User Info

To configure an individual's username and email address:

$ git config --global user.name "runoob"
$ git config --global user.email 798103175@qq.com

If the  --global  option is used, the changed configuration file is the one located in your user's home directory, and all your future projects will use the user information configured here by default.

If you want to use another name or email in a specific project, just remove the --global option and reconfigure. The new settings are saved in the current project's .git/config file.

text editor

Set the default text editor used by Git, usually Vi or Vim. If you have other preferences, such as gedit, you can reset them:

$ git config --global core.editor gedit

Difference Analysis Tool

Another common one is which diff analysis tool to use when resolving merge conflicts. For example, to use vimdiff instead:

$ git config --global merge.tool vimdiff

Git understands the output of merge tools such as kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff.

View configuration information

To check the existing configuration information, you can use the git config --list command:

$ git config --list
user.name=cakin24
[email protected]
core.editor=gedit

Sometimes you see duplicate variable names, which means they come from different configuration files (like /etc/gitconfig and ~/.gitconfig), but in the end Git actually uses the last one.

These configurations can also be seen in  ~/.gitconfig  or  /etc/gitconfig  as follows:

came ~/. gitconfig

The display is as follows:

[user]
	name = cakin24
	email = [email protected]
[core]
	editor = gedit

也可以直接查阅某个环境变量的设定,只要把特定的名字跟在后面即可,像这样:

$ git config user.name
cakin24

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326622743&siteId=291194637
Recommended