Git command - undo

Git operable revocation mainly in the following:

  1. The HEAD git the RESET $ <File> ...  # revoked the temporary file
  2. --Hard the HEAD git the RESET $     # uncommitted undo all modify the contents of the file in the working directory
  3. Checkout git $ - <File> ...   # revoke the designation does not modify the contents of the file submitted

 

1. Undo the temporary file

For already temporarily stored files,  $ git reset HEAD <file> ... command to remove the scratch. For example, the file has been staging file2.md:

After running $ git reset HEAD <file> ... command, the status of the current file is:

 

2.  revoke all uncommitted modify the contents of the file in the working directory

Without the option to call the  git reset  command is not dangerous, because it only modifies the staging area, and are not modified files in the working directory. However, if you add in the call when the call --hard option will remove all uncommitted modify the contents of the file in the working directory. For example, the state of the current file is:

Run $ git reset --hard HEAD state command file is:

 

3. revoke the designation does not modify the contents of the submission of documents

If you do not want to keep the changes to a file, it needs to be reduced to look at the last commit (or just look like clones finished, or just put it in the way when working directory). You can use  git checkout - <file> ... command, for example:

 

Note : git Checkout - [File ] is a dangerous command, you do to that file any changes will be gone, unless you really know do not want to modify the contents of that file, otherwise do not use this command.

 



 



 

Guess you like

Origin www.cnblogs.com/shichangxing/p/11441162.html