Getting started with the Git version control system

(Creating is not easy, thank you, your support is the biggest motivation for me to move forward, if it is helpful to you after reading it, please leave your footprints)

Table of contents

Introduction to Git

Git installation  

Git configuration user information

Master the Git repository

The three areas of Git 

Git file status 

Git staging area usage

Git fallback version

Delete Files  

ignore file


Introduction to Git

Concept : a free open source, distributed code version control system to help development teams maintain code
Function: record code content, switch code version, and efficiently merge code content when multiple people develop
How to learn:
Personal Native Use: Git Basic Commands and Concepts
Multi-person sharing: the team develops code version management of the same project

Git installation  

(The installation package is in my blog resource, it is expected to take 2-10 working days to pass the review o(╥﹏╥)o)

Windows system : exe program, the default is the next step
Mac system: dmg program, the default is the next step
Test succeeded:
1. Open a bash terminal (for git only)
2. Command: git -v (check the version number)

Git configuration user information

Configuration: username and email address, the application identifies itself every time a code version is submitted
Order:
git config --global user.name "xzbbl"
git config --global user.email "[email protected]"

Master the Git repository

Git warehouse ( repository ): the place where the state content of the file is recorded, and the history of modification is stored
create:
1. Convert the local folder into a Git warehouse: command git init
$ git init
Initialized empty Git repository in D:/Git学习/.git/
2. Clone the Git repository from another server

The three areas of Git 

When using Git:
Workspace : the folder operated during actual development
Temporary storage area : save the previous preparation area (temporary storage of changed files)
Repository : Submit and save the content in the temporary storage area to generate a version snapshot

 

Git file status 

Git file 2 states:
        Untracked: new files, never managed by Git
        tracked: files that Git already knows about and manages
Use: modify files, temporarily save, submit and save records, and so on
Requirements: Add a new css file, and use git status -s to view the file status, and finally submit
The first column is the staging area status
The second column is the workspace status
Not tracked:                                                                          

 Newly added:           

$ git add .

                           

 After changing the css code:

$ git status -s
A  day01/page/login/index.css

      

Git staging area usage

Temporary storage area: Temporary storage, which can temporarily restore the code content, decoupled from the version library
Staging area -> Overlay -> Workspace, command: git restore target file (note: use when fully confirming overwrite )
Remove files from the temporary storage area, command: git rm --cached target file

Git fallback version

Concept: Restore the content snapshot corresponding to a certain version of the repository to the workspace/temporary storage area
View commit history: git log --oneline
Fallback command:
git reset --soft version number (other files not tracked)
git reset --hard version number
git reset --mixed version number (equivalent to git reset)
Note 1: Only the commit records recorded in the repository can be restored
Note 2: After the rollback, continue to modify->temporary storage->submit (generate a new submission record process)

Delete Files  

Requirement: Delete the editor.js file and generate a version record
step:
1. Manually delete workspace files
2. Temporary storage changes/manual deletion of temporary storage area files cause changes
3. Submit and save
Summarize:
As long as the workspace changes, it can be submitted temporarily to generate new records

ignore file

Concept: The .gitignore file allows git to completely ignore tracking specified files
Purpose: To make the git warehouse smaller and faster, to avoid repeated meaningless file management
For example:
1. Files automatically generated by the system or software
2. Compile the resulting file
3. Log files, cache files, temporary files, etc. generated during runtime
4. Confidential documents, passwords, secret keys and other documents
create:
1. Create a new .gitignore file in the project root directory
2. Fill in the corresponding configuration to ignore the specified file
Note: If the file has been tracked by the temporary storage area, it can be removed from the temporary storage area

Guess you like

Origin blog.csdn.net/weixin_73295475/article/details/131900963