(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
Git configuration user information
Introduction to Git
Concept : a free open source, distributed code version control system to help development teams maintain codeFunction: record code content, switch code version, and efficiently merge code content when multiple people developHow to learn:Personal Native Use: Git Basic Commands and ConceptsMulti-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 stepMac system: dmg program, the default is the next stepTest 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 submittedOrder: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 storedcreate: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 developmentTemporary 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 Gittracked: files that Git already knows about and managesUse: modify files, temporarily save, submit and save records, and so onRequirements: Add a new css file, and use git status -s to view the file status, and finally submitThe first column is the staging area statusThe 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 libraryStaging 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 areaView commit history: git log --onelineFallback command:git reset --soft version number (other files not tracked)git reset --hard version numbergit reset --mixed version number (equivalent to git reset)Note 1: Only the commit records recorded in the repository can be restoredNote 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 recordstep:1. Manually delete workspace files2. Temporary storage changes/manual deletion of temporary storage area files cause changes3. Submit and saveSummarize: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 filesPurpose: To make the git warehouse smaller and faster, to avoid repeated meaningless file managementFor example:1. Files automatically generated by the system or software2. Compile the resulting file3. Log files, cache files, temporary files, etc. generated during runtime4. Confidential documents, passwords, secret keys and other documentscreate:1. Create a new .gitignore file in the project root directory2. Fill in the corresponding configuration to ignore the specified fileNote: If the file has been tracked by the temporary storage area, it can be removed from the temporary storage area