Home > php教程 > PHP开发 > Detailed explanation of installation and configuration of Git tutorial

Detailed explanation of installation and configuration of Git tutorial

黄舟
Release: 2016-12-16 14:43:32
Original
1101 people have browsed it

Git installation configuration

We need to install Git before using Git. Git currently supports Linux/Unix, Solaris, Mac and Windows platforms.
Git The download address of the installation package for each platform is: http://git-scm.com/downloads

The installation of

Git on the Linux platform requires calling the code of curl, zlib, openssl, expat, libiconv and other libraries, so it is necessary Install these dependent tools first.
There is yum On a system (such as Fedora) or a system with apt-get (such as Debian system), you can use the following command to install:
Linux The system can be easily installed using its installation package management tool:

Debian/Ubuntu

Debian/Ubuntu Git installation command is:

$ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
 libz-dev libssl-dev
  
$ apt-get install git-core
  
$ git --version
git version 1.8.1.2
Copy after login

Centos/RedHat

If the system you are using is Centos /RedHat 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.7.1
Copy after login

Installation on Windows platform

It is equally easy to install Git on Windows platform. There is a project called msysGit that provides an installation package. You can download the exe from the GitHub page. Install the file and run:

Installation package download address: http://msysgit.github.io/


Detailed explanation of installation and configuration of Git tutorial

After completing the installation, you can use the command line git tool (already included) ssh client), and there is also a graphical interface for Git Project management tools.
Find "Git"->"Git Bash" in the start menu, the Git command window will pop up, and you can perform Git operations in this window.

Installation on Mac platform

The easiest way to install Git on Mac platform is to use the graphical Git installation tool. The download address is:
http://sourceforge.net/projects/git-osx-installer/

The installation interface is as follows:

Detailed explanation of installation and configuration of Git tutorial

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 the specific working methods and behaviors of Git in each link. These variables can be stored in three different places:

/etc/gitconfig file: a configuration that is common to all users in the system. If using git config use --system option, it is this file that is read and written.

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

The configuration file in the Git directory of the current project (that is, .git/config in the working directory file): The configuration here is only valid for the current project. The configuration at each level will overwrite the same configuration at the upper level, so the configuration in .git/config will overwrite /etc/gitconfig variable with the same name in .

On Windows systems, Git will look for the .gitconfig file in the user's home directory. The home directory is the directory specified by the $HOME variable, usually C:Documents and Settings$USER.

In addition, Git will also try to find the /etc/gitconfig file, but it depends on the directory where Git was originally installed, and uses this as the root directory to locate it.

User information

Configure personal user name and email address:

$ git config --global user.name "runoob"
$ git config --global user.email test@runoob.com
Copy after login

If the --global option is used, the changed configuration file is the one located in your user home directory, and all your future projects The user information configured here will be used 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 .git/config of the current project. in the file.

Text Editor

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

$ git config --global core.editor emacs
Copy after login

Diff Analysis Tool

Another commonly used one is which diff analysis tool to use when resolving merge conflicts. For example, if you want to switch to vimdiff:

$ git config --global merge.tool vimdiff
Copy after login

Git can understand kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff Wait for the output information of the merge tool.
Of course, you can also specify to use tools developed by yourself. Please refer to Chapter 7 for details on how to do this.

View configuration information

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

$ git config --list
http.postbuffer=2M
user.name=runoob
user.email=test@runoob.com
Copy after login

Sometimes you see duplicate variable names, which means they come from different configurations files (such as /etc/gitconfig and ~/.gitconfig), but ultimately Git The last one is actually used.

We can also see these configurations in ~/.gitconfig or /etc/gitconfig, as shown below:

vim ~/.gitconfig
Copy after login

The displayed content is as follows:

[http]
 postBuffer = 2M
[user]
 name = runoob
 email = test@runoob.com
Copy after login

You can also directly check an environment variable To set, just follow the specific name, like this:

$ git config user.name
runoob
Copy after login

以上就是Git 安装配置的资料,更多相关文章请关注PHP中文网(m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template