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

Detailed explanation of installation and configuration of Git tutorial

Dec 16, 2016 pm 02:43 PM

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中文网(www.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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run the h5 project How to run the h5 project Apr 06, 2025 pm 12:21 PM

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

How to specify the database associated with the model in Beego ORM? How to specify the database associated with the model in Beego ORM? Apr 02, 2025 pm 03:54 PM

Under the BeegoORM framework, how to specify the database associated with the model? Many Beego projects require multiple databases to be operated simultaneously. When using Beego...

Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Gitee Pages static website deployment failed: How to troubleshoot and resolve single file 404 errors? Apr 04, 2025 pm 11:54 PM

GiteePages static website deployment failed: 404 error troubleshooting and resolution when using Gitee...

Which libraries in Go are developed by large companies or provided by well-known open source projects? Which libraries in Go are developed by large companies or provided by well-known open source projects? Apr 02, 2025 pm 04:12 PM

Which libraries in Go are developed by large companies or well-known open source projects? When programming in Go, developers often encounter some common needs, ...

How to solve the user_id type conversion problem when using Redis Stream to implement message queues in Go language? How to solve the user_id type conversion problem when using Redis Stream to implement message queues in Go language? Apr 02, 2025 pm 04:54 PM

The problem of using RedisStream to implement message queues in Go language is using Go language and Redis...

Does H5 page production require continuous maintenance? Does H5 page production require continuous maintenance? Apr 05, 2025 pm 11:27 PM

The H5 page needs to be maintained continuously, because of factors such as code vulnerabilities, browser compatibility, performance optimization, security updates and user experience improvements. Effective maintenance methods include establishing a complete testing system, using version control tools, regularly monitoring page performance, collecting user feedback and formulating maintenance plans.

How to convert xml to excel How to convert xml to excel Apr 03, 2025 am 08:54 AM

There are two ways to convert XML to Excel: use built-in Excel features or third-party tools. Third-party tools include XML to Excel converter, XML2Excel, and XML Candy.

In Go programming, how to correctly manage the connection and release resources between Mysql and Redis? In Go programming, how to correctly manage the connection and release resources between Mysql and Redis? Apr 02, 2025 pm 05:03 PM

Resource management in Go programming: Mysql and Redis connect and release in learning how to correctly manage resources, especially with databases and caches...

See all articles