Pro Git chapter 1 study notes: getting started (introduction to version control), git installation and configuration, etc.


Learn more about git strongly recommend Pro Git Chinese version

1.1 Version control system

1.1.1 Definition

  A version control system is a system that records changes in the content of one or several files for future review of specific version revisions. Any type of files, as long as they need to be updated, version control is very helpful.
  Version control means recording every file modification (modified content and reason), and you can trace the selected file back to the state of any previous version.

1.1.2 Different version control systems

Local version control system Centralized version control system Distributed Version Control System
  From left to right is the local version control system (Local Version Control Systems), centralized version control system (Centralized Version Control Systems, CVCS) , a distributed version control system (Distributed Version Control System, DVCS)
  local version control system A simple database is used locally to record the differences of previous updates of files. The most popular one is called RCS. The principle is to save a patch set on the hard disk and calculate the content of each version of the file by applying the patch. It can be seen on many computer systems today.
  CVCS allows developers of different systems to work together, and administrators can easily control the permissions of each developer.
  The DVCS client not only extracts the latest version of the file snapshot, but also mirrors the code repository completely, including the complete history. Such systems can be specified to interact with several different remote code repositories. With this, you can collaborate with people from different working groups on the same project. Such systems include Git, Mercurial, Bazaar, Darcs, etc.

1.2 Introduction to git

1.2.1 A brief history of git

  The Linux kernel open source project has a large number of participants. Between 1991 and 2002, most of the Linux kernel maintenance work was spent on the tedious tasks of submitting patches and keeping archives. By 2002, the entire project team began to use a proprietary distributed version control system BitKeeper to manage and maintain code.
  In 2005, the commercial company that developed BitKeeper ended its partnership with the Linux kernel open source community, and they took back the right of the Linux kernel community to use BitKeeper for free. This forces the Linux open source community (especially Linus Torvalds, the creator of Linux) to develop its own version system based on the experience and lessons learned when using BitKeeper. They set several goals for the new system:
  1. Speed
  2. Simple design
  3. Strong support for non-linear development mode (allowing thousands of parallel development branches)
  4. Fully distributed
  5. Ability and efficiency
  Since the birth of super large-scale projects (speed and data volume) similar to the Linux kernel , Git has become more mature and perfect. While highly easy to use, it still retains its initial goals. It's fast, it's extremely suitable for managing large projects, and it has an incredible non-linear branch management system

1.2.2 Introduction to git

Store the difference between each file and the initial version Store snapshots of changes over time
  The main difference between git and other version control systems is the way git treats data . Most version control systems are delta-based, such as CVS, Subversion, Perforce, Bazaar, etc. These systems view the information they store as a set of basic files and the cumulative differences of each file over time.
  In Git, whenever you submit an update or save the project state, it basically creates a snapshot of all the files at that time and saves the index of this snapshot. For efficiency, if the file is not modified, Git will not re-store the file, but only keep a link to the previously stored file.
  Most operations in Git only need to access local files and resources
  Git to ensure integrity. All data in Git calculates a checksum before storing, and then refers to it with the checksum. This means that it is impossible to change the contents of any file or directory without Git's knowledge.
  Git operations almost only add data to the Git database. So once you submit a snapshot to Git, it is difficult to lose data

1.2.3 git status and workflow

  The three states of git are the most important things (one of) when using git. Git has three states: committed (committed), modified (modified) and staged (staged).
  -Modified means that the file has been modified but has not been saved in the database.
  -Staging means that the current version of a modified file is marked to be included in the next snapshot.
  -Submitted means that the data has been safely stored in the local database.

   The basic git workflow is:-Modify
  files in the workspace.
  -Optionally save the changes you want to submit next time, so that only the changed part will be added to the staging area.
  -Submit the update, find the file in the staging area, and store the snapshot permanently in the Git directory.

1.3 Installation and configuration

1.3.1 How to use git

  You can use the native command line mode or the GUI mode. The command line mode is king.

1.3.2 git installation

  Go to the official website to download and install

1.3.3 git configuration information

  Git comes with a git config tool to help set configuration variables that control the appearance and behavior of Git. These variables are stored in three different locations: /etc/gitconfig, ~/.gitconfig or ~/.config/git/config file, the config file in the Git directory of the current repository (ie .git/config). They are the general configuration of each user of the operating system, the general configuration of the current user, and the configuration of the current warehouse. Passed separately when modifying --system, --global, --local.
  On Windows systems, Git will look for the .gitconfig file in the $HOME directory (usually C:\Users\$USER).
  You can view all the configurations and the files they are in with the following command:
$ git config --list --show-origin

1.3.4 Configure user information

  After installing Git, the first thing to do is to set up your username and email address. This is very important, because every Git commit will use this information. They will be written to each of your commits and cannot be changed ( note that you cannot modify the information of the previous version, not the configuration ):
$ git config --global user.name "John Doe"
$ git config --global user.email [email protected]

1.3.5 Check configuration information

  Use to git config --listlist the current git configuration, use such as to git config user.nameview a certain configuration

1.4 Get help

  Use git help [verb], git [verb] --help, man git-[verb] to find the manual for git commands, such as git help configthe command manual for git config.
  To get a brief usage, use the -h parameter, if you want to get help from git add command line inputgit add -h

Guess you like

Origin blog.csdn.net/qq_34769162/article/details/108609773