Git study notes

What is Git?

Git is a project version control tool that manages projects in a distributed manner. The
same project management tool, the more popular one is SVN, which belongs to a centralized version control system

Bash & CMD & GUI

Git Bash, Git CMD, Git GUI, are three ways of Git operation, generally we choose to use Git Bash

Git Bash: Linux-style command line
Git CMD: Windows-style command line
Git GUI: GUI for Git operations

Basic Linux Commands

Because we generally use Git Bash, we need to have a certain understanding of Linux operation:

  • cd ... means: go back to the previous directory (note: there is a space between cd and ...)
  • cd means: jump to the specified directory, which can be an absolute position or a relative position (note: there is also a space between cd and the path)
  • pwd means: directly display the current path
  • ls(-l) means: list all files in the current directory, ll in parentheses is optional, which means the display information is more detailed
  • touch xx.txt means: create a file called xx.txt
  • rm xx.txt means: delete the file named xx.txt
  • mkdir xx means: create a folder named xx
  • rm -r xx means: delete a folder named xx, note that there is a space between rm and -r, and there is also a space between -r and xx
  • mv xx.js yy means: move the xx.js file in the current directory to the yy folder
  • reset means: reinitialize the terminal, which is actually the same as the clear effect
  • clear means: clear the screen, in windows it is cls
  • history means: view history commands
  • help means: help
  • exit means: exit
  • #means: comment

Necessary configuration for Git

  • git config -l means: view the current git configuration
  • git config --system --list: means: view some information about the system configuration
  • git config --global --list: means: view some information about the global user configuration
  • git config --global user.name "XXX" means: set the global user name to XXX
  • git config --global user.email "[email protected]" means: set the global user mailbox to [email protected]

Principles of Git

Work area
Git has three local work areas: the working directory (Working Directory), the staging area (Stage/Index), and the repository (Repository or Git Directory). If you add a remote git repository (Remote Directory), it can be divided into four working areas. The conversion relationship of files between these four areas is as follows:
insert image description here

Workspace: Workspace, which is where you usually store your project code
Index / Stage: Temporary storage area, used to temporarily store your changes, in fact, it is just a file to save the information about to be submitted to the file list
Repository: warehouse area (or local Repository), which is where the data is safely stored, which contains the data you submitted to all versions. Where HEAD points to the latest version of the repository
Remote: remote repository, the server hosting the code, it can be simply thought of as a computer in your project team for remote data exchange

The three local areas should be exactly the version pointed to by HEAD in the git repository
insert image description here

Directory: A directory managed by Git, that is, a repository, including our workspace and Git's management space.
WorkSpace: The directories and files that need to be version controlled by Git, and these directories and files make up the workspace.
.git: The directory for storing Git management information, which is automatically created when the warehouse is initialized.
Index/Stage: The staging area, or the update area to be submitted, we can put all the updates in the staging area before submitting them into the repo.
Local Repo: Local repository, a repository stored locally; HEAD will just be the current development branch.
Stash: Hidden, is a working state save stack, used to save/restore the temporary state in the WorkSpace.

work process

The workflow of git is generally like this:

1. Add and modify files in the working directory;

2. Put the files that need version management into the temporary storage area;

3. Submit the files in the staging area to the git repository.

Therefore, files managed by git have three states: modified, staged, and
insert image description here
committed
insert image description here

references

https://www.cnblogs.com/best/p/7474442.html#_lab2_2_0
https://www.bilibili.com/video/BV1FE411P7B3?p=5&spm_id_from=pageDriver

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325964848&siteId=291194637