Management and modification of Git undo changes

Modify management

git tracking and management is modified, not the file, including additions and deletions to modify or add files to an existing file

If you do not git add files after modification, but directly git commit, then git does not modify the record, because there is no submit modified files to the staging area
Here Insert Picture Description
then just run git add git commit before execution can
Here Insert Picture Description
undo changes

I. files are not submitted to the staging area after modification, or submit to the staging area is changed again, this time when you want to withdraw
the revocation modified using the command: git checkout - file (file name) where the "-" very important and must not omit
this command means that the file readme.txt complete withdrawal by modifying the work area, where two cases:
(1) readme.txt file has not been modified since placed in temporary storage area, now , and undo changes is to return to the state of the repository exactly the same (even if the data will be added together several times revoked)
(2) the Readme.txt file has been added to the staging area after he was revised, now revoked modification adding to return to the state after staging area
in short, it is to make the file back to the state when the last git add or git commit

Case 2, the revised submitted to the staging area, but withdrawn when needed:
(1) the RESET head git file name: Use this command to withdraw the document from scratch to (at this time has not revoked the modification)
(2) git Checkout - file name: the implementation of a command to withdraw from scratch

After three cases, git commit submitted wants to withdraw, you can follow the version rollback

Guess you like

Origin blog.csdn.net/weixin_43190860/article/details/91412202