git-scm官网上checkout说明:
https://git-scm.com/docs/git-checkout
git checkout [<tree-ish>] [--] <pathspec>…
Overwrite paths in the working tree by replacing with the contents in the index or in the <tree-ish> (most often a commit). When a <tree-ish> is given, the paths that match the <pathspec> are updated both in the index and in the working tree.
The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the checkout operation will fail and nothing will be checked out. Using -f will ignore these unmerged entries. The contents from a specific side of the merge can be checked out of the index by using --ours or --theirs. With -m, changes made to the working tree file can be discarded to re-create the original conflicted merge result.
- 修改并push至版本区
[root@SDN-5668-1 runoob]# vim readme.txt
[root@SDN-5668-1 runoob]# cat readme.txt
1.版本区
[root@SDN-5668-1 runoob]# git add readme.txt
[root@SDN-5668-1 runoob]# git commit -m "版本区"
[root@SDN-5668-1 runoob]# git push
- 修改并add到暂存区
[root@SDN-5668-1 runoob]# vim readme.txt
[root@SDN-5668-1 runoob]# cat readme.txt
1.版本区
2.暂存区
[root@SDN-5668-1 runoob]# git add readme.txt
- 修改工作区并检查状态
[root@SDN-5668-1 runoob]# vim readme.txt
[root@SDN-5668-1 runoob]# cat readme.txt
1.版本区
2.暂存区
3.工作区
- checkout暂存区至工作区
[root@SDN-5668-1 runoob]# git checkout -- readme.txt
[root@SDN-5668-1 runoob]# cat readme.txt
1.版本区
2.暂存区