May 25, 2021 Git
1. Git installation configuration
2. Installed on the Linux platform
3. Installed on the Windows platform
We need to install Git before we can use it. Git currently runs on Linux/Unix, Solaris, Mac, and Windows platforms.
Git platform installation package download address is: http://git-scm.com/downloads
Git's work requires calling the code for libraries such as curl, zlib, openssl, expat, libiconv, and so on, so you need to install these dependency tools first.
On systems with yum (e.g. Fedora) or on systems with apt-get (e.g. Debian systems), you can install them with the following commands:
Each Linux system can simply use its installation package management tools for installation:
The Debian/Ubuntu Git installation commands are:
$ 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
If you are using a 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
Installing Git on a Windows platform is just as easy, with a project called msysGit that provides an installation package to download the exe installation file from the GitHub page and run it:
Installation package download address: http://msysgit.github.io/
Once installed, you're ready to use the command-line git tool, which already has its own ssh client, and a Git project management tool with a graphical interface.
When you find "Git" - "Git Bash" in the start menu, a Git command window pops up where you can do Git.
The easiest way to install Git on a Mac platform is to use a graphical Git installation tool at:
http://sourceforge.net/projects/git-osx-installer/
The installation interface looks like this:
Git provides a tool called git config, which is designed to configure or read the appropriate work environment variables.
These environmental variables determine how Git works and behaves at each stage. T hese variables can be stored in three different places:
/etc/gitconfig
Configuration that is generally applicable to all users in the system.
If you use the --system option when
--system
git config
read and write this file.
~/.gitconfig
The profile in the user directory applies only to that user.
If you use the --global option when
--global
git config
read and write this file.
.git/config
The configuration here is valid only for the current project.
Each level of configuration overrides the same configuration at the upper layer,
.git/config
/etc/gitconfig
On Windows systems, Git searches for .gitconfig files in the user's home directory. The home directory is $HOME the directory specified by the variable, and is generally a C: . . . documents and Settings $USER.
In addition, Git will try to find /etc/gitconfig files, just to see what directory Git was installed in the first place, as the root to locate.
Configure an individual's user name and email address:
$ git config --global user.name "w3c" $ git config --global user.email [email protected]
If the --global option is used, the changed profile is the one located in your user's home directory, and all of your projects will use the user information configured here by default.
If you want to use a different name or email in a particular project, simply remove the --global option reconfiguration and save the new settings in the .git/config file for the current project.
Set the text editor that Git uses by default, typically Vi or Vim. If you have other preferences, such as Emacs, you can reset:
$ git config --global core.editor emacs
It is also more commonly used to use a difference analysis tool when resolving merge conflicts. F or example, if you want to use vimdiff between words:
$ git config --global merge.tool vimdiff
Git understands the output of combined tools such as kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff.
Of course, you can also specify how to use the tools you've developed, as you can see chapter 7.
To check for existing configuration information, you can use the 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 you see duplicate variable names, which means that they come from different profiles (such as /etc/gitconfig and ./.gitconfig), but in the end Git actually uses the last one.
You can also look directly at the settings of an environment variable, as long as you follow a specific name, like this:
$ git config user.name Scott Chacon