Before reading this blog post, please follow my detailed instructions on the git diff command, only in order to have a detailed understanding of the git reset command;
Let's see what git reset is.
An important task of a version control system is to provide the ability to undo and redo a stage of work.
The Git-reset command is intended for such a task, and it can target the current version of the project to the previous commit
In any version of the.
The Git-reset command has three options:--mixed,--soft, and--hard. We use it on a daily basis
Only the first two options are used, and the third option is prone to damage to the project warehouse due to its high lethality and the need to carefully
Use.
--mixed is the default option for Git-reset, which is to reset the index content and position it to the specified
Project version without changing all of the content in your work tree, just to indicate which files you have not yet updated.
The--soft option does not touch the index's location, nor does it change anything in the work tree, but requires
They are in a good order. This option preserves all of your updates in the work tree and makes them
Pending submission status.
The above is an introduction:
Simply put, git reset is reset content;
-mixed is to reset the contents of the index, the following is its test:
Dzfdeimac:git xuyaowen$ Cat Git.txt-Prints out the contents of the test material
This is the first file to sync with github remotely!
This is the second time this is modified!
This is the data added to the--mixed test.
Dzfdeimac:git xuyaowen$ Nano Git.txt--to modify the contents of the test material
dzfdeimac:git xuyaowen$ git diff--Shows the difference between a work tree and an index table
Diff--git A/git.txt B/git.txt
Index aac3d8a: 82ada7f 100644
---a/git.txt
+ + B/git.txt
@@ -1,3 +1,4 @@
This is the first file to sync with github remotely!
This is the second time this is modified!
This is the data added to the--mixed test.
+ This is the test data for--mixed
dzfdeimac:git xuyaowen$ git diff--cached--Shows the difference between the contents of the Index table and the codebase, and finds no difference
Dzfdeimac:git xuyaowen$ git Add. --Add the current content to the index table
dzfdeimac:git xuyaowen$ git diff--Compare the contents of the index table with the code tree, no difference
dzfdeimac:git xuyaowen$ git diff--cached--Compare the differences between the contents of the Index table and the codebase, indicating that the index table has been updated;
Diff--git A/git.txt B/git.txt
Index aac3d8a: 82ada7f 100644
---a/git.txt
+ + B/git.txt
@@ -1,3 +1,4 @@
This is the first file to sync with github remotely!
This is the second time this is modified!
This is the data added to the--mixed test.
+ This is the test data for--mixed
Dzfdeimac:git xuyaowen$ git reset--mixed --use--mixed to reset the contents of the Index Table
Unstaged changes after Reset:
M Git.txt
dzfdeimac:git xuyaowen$ git diff compares the contents of the index table with the work tree, and finds that there are differences;
Diff--git A/git.txt B/git.txt
Index aac3d8a: 82ada7f 100644
---a/git.txt
+ + B/git.txt
@@ -1,3 +1,4 @@
This is the first file to sync with github remotely!
This is the second time this is modified!
This is the data added to the--mixed test.
+ This is the test data for--mixed
dzfdeimac:git xuyaowen$ git diff--cached compares the difference between the index table and the code base, and the discovery has disappeared, indicating that the contents of the index table are back;
The same can be verified, git reset--soft The effect of the situation, pay attention to the ability to improve themselves;
Please pay attention to, small red flag, blog address is: Http://blog.csdn.net/happylaoxu point I direct access: small red flag blog, point me: Http://blog.csdn.net/happylaoxu
Please continue to focus on the follow-up to Git's explanation;
Git uses instructions on how to use git reset, and the usage of its main plugin;