Skip to content

Instantly share code, notes, and snippets.

@lajunta
Created October 30, 2013 01:15
Show Gist options
  • Save lajunta/7225672 to your computer and use it in GitHub Desktop.
Save lajunta/7225672 to your computer and use it in GitHub Desktop.
我们本地的git目录下, 其实分为三种类型的文件: working tree、index file和native repository;
working tree就是我们当前修改的文件;
在使用"git add"命令后, git就会把diff合入index file(通过“git diff”来查看working tree与index file的差别);
再使用"git commit"命令, 把修改合入native repository("git commit -a"相当于"git add" + "git commit"; 在commit之前, 可以通过""git diff --cached"来查看index file与commit的差别);
其实, 还可以使用"git reset"命令来还原git节点.
"git reset --hard patch-hash-name" 可以使working tree、index file以及native repository彻底回复到指定的节点;
"git reset --mixed patch-hash-name" 可以使index file和native repository被还原;
"git reset --soft patch-hash-name" 可以使native repository被还原;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment