Git -- "Git installation and configuration

Table of contents

Getting to know Git

version control

How Git works

Git installation and configuration

Window platform installation (lecturer)

Linux platform installation

Mac platform installation

Git configuration


Getting to know Git

Before learning Git , we should understand why we should learn Git and what Git can do for us :

For example, in daily development, multiple people write code for a shared file, and each person has their own version. If you do not borrow Git, the modifications made by the person who edited first will be overwritten, or if the customer requests The version of your code was written before, but now the previous writing has been deleted, and the previously edited version cannot be found. This is very pitiful. Based on this situation, the Git version management system came into being.

Git is a free, open source distributed version control system that can efficiently handle various projects from small to large; Git is easy to learn, has a small footprint, and has extremely fast performance. It features an inexpensive native library, convenient suspending areas, and multiple workflow branches. It outperforms version control tools like Subversion, CVS, Perforce, and ClearCase.

version control

Version control is a system that records changes in file content for future revisions of specific versions . It is used to manage our modification history of files, directories, or projects during the development process, so that we can view the history of changes, and make backups to restore previousversion of software engineering techniques. The most important thing is that it can record the history of file modification, so that users can view historical versions and facilitate version switching. Simply put : technology for managing multi-person collaborative development projects.

Version Control Classification:

Local version control :

Record each file update, you can make a snapshot of each version, or record patch files, suitable for individuals, such as RCS.

Centralized version control :

All version data are stored on the server, and developers can synchronize updates or upload their own modifications from the server. The disadvantage is : once the server is damaged or has network problems, users cannot see the historical version or even lose all data. Product: SVN

Distributed version control :

All version information warehouses are synchronized to each local user, so that you can view all version history records, just push to the corresponding server or other users when connecting to the Internet, it will not work due to server or network problems. The situation, the disadvantage is : everyone has all the codes, which is easy to cause security risks, such as running away with the code...

The difference between Git and SVN :

Git is a distributed version control system . There is no central server. Everyone's computer is a complete version library. It does not need to be connected to the Internet when working, because the versions are all on their own computers, and you can directly see the updated codes and files.

SVN is a centralized version control system . The version library is centralized in the central server. When working, you need your own computer to get the latest version from the central server, and then work. After the work is completed, the completed content is pushed to the central server.

Common version control tools:

Git、SVN、CVS、VSS、TFS、Visual Studio Online

There are many version control products, and now Git is the most influential and widely used technology. We should also learn Git, the most mainstream technology. Others can be understood.

How Git works

The code hosting center is a remote code repository based on a web server, generally referred to as " remote repository ".

There are basically two types of hosting centers : GitLab on the local area network, Github (external network) and Gitee (code cloud, domestic website) on the Internet

Git installation and configuration

Window platform installation (lecturer)

To install Git on the Windows system, you can download it from the Git official website: Git official website (a foreign station, if the download is slow, you can find some domestic mirror websites, there are many Baidu, and I will not repeat them here)

It is recommended to check these options during the installation process. You can right-click on the desktop and you can see it in the menu bar.

When choosing a default editor, you can directly choose vim by default, just go back to Linux operation, of course, you can also choose other editors that you are good at, mainly depending on your specific situation.

When you choose to set the branch name, you can simply default it.

When selecting the PATH environment, you can choose the first one, the second one can also be run in cmd, and the third one is not recommended.

The following direct fool-like default can be used directly, and there is nothing important to explain.

After the installation is complete, you can use the command line git tool, and there is also a graphical interface Git project management tool, find "Git"->"Git Bash" in the start menu, the Git command window will pop up, you can go to This window performs Git operations.

Git Bash: Unix and Linux-style command line, most used, most recommended

Git CMD: Windows-style command line

Git GUI: Git with graphical interface, not recommended for beginners, try to be familiar with common commands first

The graphical interface of Git GUI is ugly, and most of them still prefer to use Git Bash.

Click on Git Bash and enter git --version to view the current version of git, because I downloaded it a long time ago, it is not the latest version, and I am too lazy to update and download it again. Let’s make do with it (hold down ctrl + scroll wheel) Enlarge the font), enter basic Linux commands in the input box to execute.

Linux platform installation

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. On systems with yum (such as Fedora) or systems with apt-get (such as Debian systems), you can use the following command to install: Each Linux system can easily use its installation package management tool to install:

The Git installation command in Debian/Ubuntu 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

The Git installation command in Centos/RedHat 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

Mac platform installation

The easiest way to install Git on the Mac platform is to use the graphical Git installation tool, whose download address is: Git installation

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 mode and behavior of Git in each link. 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.

The specific configuration of using Git will continue to be explained in the next section:

Guess you like

Origin blog.csdn.net/qq_53123067/article/details/126641673