git reset head, checkout_git

Source: Internet
Author: User
Reset and checkout similarities and differences can achieve the same function, such as restoring local files, but reset more emphasis on "undo", such as revocation registers, undo registers and local, and checkout more emphasis on "replacement", such as the use of registers content to replace local, Use head to point directory to replace registers and local. Reset, undo git reset Head-filename
Undo the last staging (cancel registers content, replace the staging area with the directory (version library) pointed to by head) If you only delete staging and keep the workspace, you can use git rm--cached-r filename,-r to indicate that you want to delete the git reset--hard head:
Undo all changes to local and registers (the directory pointed to by Head (version Library) replaces local and registers) git Reset–hard origin/master
Undo local, registers, version libraries (replace local, registers, version libraries with origin/master of remote servers) checkout emphasis, replace

git checkout [--] filename
-Replaces the workspace file with the registers content. For example, working directory has changed, but want to discard these changes, then use git checkout--a.txt discard the changes to A.txt
git checkout head filename
-Replaces the registers and workspace file head with the directory (version library) pointed to by head

The head is often used in Git's commands to see the head as a pointer, a local version of the library, and a head that can be replaced with a remote library, for example, Origin/master,origin represents an address, and master is a branch. Origin

-Origin represents the address of the remote warehouse, in config file, as

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.