2022-01-26 22:25:51 【X-77】
The previous article introduced npm Tools , This is still a tool ~ This time it's about Git Tools ！
One 、 What is? Git
Git Is an open source distributed version control system , It's the most advanced 、 The most popular version control system .
characteristic ： The bigger the project, the more complex , The more collaborative developers , The more you can show Git Of High performance and High availability .
Git Three states of ：
Git workflow ：
1. Modify the file in the workspace
2. Staging changes you want to commit next time
3. Submit update , Find the file in the staging area , Permanently store the snapshot to Git Warehouse
Two 、Git download
Download address ：Git
After downloading and installing , Right click the blank space , When you see the following message, the installation is successful .
After installation, we need to make some configuration . Facilitate the follow-up when developing projects with multiple people , Know who modified the workspace file . If used --global Options , You only need to run once , That is, it can take effect permanently .
git config --global user.name " user name "
git config --global user.email " mailbox "
View configuration information ：
git config --list --global（ View global configuration items ）
When we need help , have access to git help command , You can open the help manual on the Internet without networking
git help <verb> // Get the full version of the manual
git <verb> -h // Get a more concise ”help“ Output
3、 ... and 、Git operation
git Four states in the workspace ：
In the project directory （ work area ） Open in "Git Bash", And implement git init The command changes the current directory to Git Warehouse . This command creates a file named .git Hidden directory for , Is the of the current project Git Warehouse , Contains the initial necessary files , yes git A necessary part of the warehouse .
git init // initialization Git Warehouse
here , All files in the workspace are in the unused state Git Tracked files . We can go through git status To check the status of the file .
git status // View the status of the file
git status -s // View the compact status of the file
Show statement State description ?? Not by git Tracked files A Files newly added to the staging area M A modified 、 Files not in the staging area M
A modified , Files that have been put into the staging area
2. Track new files
Use git add The command starts tracking a new file .
git add The role of ：
1. You can use it to start tracking new files
2. Put tracked 、 And the modified files are put in the temporary storage area
3. Mark conflicting files as resolved
When we want to track multiple new files at once / Add multiple modified files to the staging area ：git add .
Check the status and you can see the following information , It means that it is in the state of being stored in the temporary storage area at this time .
3. Submit update
git commit -m ” Describe the message “// Save the staging area file to Git Warehouse
After running the statement , Again using git status Check file status , You will find that the following information is returned ：
At this point, it means that all files in the workspace are git track , And save it as a snapshot to git Warehouse .
When we modify the contents of the file in the workspace , Need to reuse git add Commit the file to the staging area , Reuse git commit -m Command submit update .
4. Cancel the temporary file
git reset HEAD Name of the file to be removed // Restore the file to the state before staging
5. Skip using staging area
git commit -a -m ” Describe the message “ // Simplify the workflow ： work area -> Git Warehouse
6. Undo changes to the document
git checkout -- file name // Undo changes to the document
7. remove file
git rm -f file name // from Git Remove files from warehouse and workspace at the same time
git rm -cached file name // Remove only Git Documents in storage , Keep files in the workspace
8. Ignore files
Some documents do not need to be included Git management , But we don't want them to always appear on the untracked file list . We can create a .gitignore Configuration file for , List the matching patterns of the files you want to ignore .
file .gitignore The format specification of is as follows ：
With # start Note
With / ending It's the directory
With / start Prevent recursion
With ! start Representation inversion
have access to glob Pattern to match files and folders
9. View the submission history
git log // View the history of all submissions
git log - Numbers // Show the submission history of the specified number of entries
git log -2 --pretty=online // Display the last two submission history on one line
git log -2 --pretty=format:"%h | %an | %ar | s " Show the last two submission history on one line , And customize the output format .
notes ：%h The abbreviated hash value submitted %an Author's name %ar Author's revision date , Show... In the way it used to be %s Submit instructions
10. Back to the specified version
Git Each upload is a version snapshot , So we can quickly switch versions .
git reset --hard <CommitID> // Submit according to the specified ID Back to the specified version
When we want to go back to the previous version in the latest version , You need to display the submission history on one line ：git log --pretty=oneline sentence . And when we want to go back to the new version in the old version , You need to use another statement to query the history ： git relog --pretty=oneline
Four 、 summary
Git Is a very easy to use version control system , stay git There are many sentences in , One of the most important is initialization Git Orders from the warehouse 、 Commands for viewing file status 、 Command to add files to the staging area as well as Submit files from staging area to Git Orders from the warehouse . If you don't know these four orders, you will be punished to read the article again ！
notice Github Do you feel familiar with ！ you 're right , This is the world's best open source project hosting platform , Only support Git As the only version control tool . In the future, we can put the local Git Upload warehouse to Github Study with you on 、 communication .
author[X-77],Please bring the original link to reprint, thank you.
The sidebar is recommended
- Spring IOC container loading process
- [thinking] the difference between singleton mode and static method - object-oriented programming
- Force deduction algorithm - 92 Reverse linked list II
- What is the sub problem of dynamic programming?
- C / C + +: static keyword summary
- Idea does not have the artifacts option when configuring Tomcat
- I don't know how to start this
- MySQL slow log optimization
- [Vue] as the window is stretched (larger, smaller, wider and higher), the text will not be displayed
- Two pronged approach, Tsinghua Professor Pro code JDK and hotspot source code notes, one-time learning to understand
guess what you like
C + + recursive knapsack problem
The use of GIT and GitHub and the latest git tutorial are easy to understand -- Video notes of crazy God speaking
Ignition database test
A list that contains only strings. What other search methods can be used except sequential search
[matlab path planning] multi ant colony algorithm grid map path planning [including GUI source code 650]
[matlab path planning] improved genetic algorithm grid map path planning [including source code phase 525]
Reactnative foundation - 07 (background image, status bar, statusbar)
Reactnative foundation - 04 (custom rpx)
Java project: OA management system (java + SSM + bootstrap + MySQL + JSP)
[data structure] chain structure of binary tree (pre order traversal) (middle order traversal) (post order traversal) (sequence traversal)