Git程序员Git

git 撤销操作

2017-08-24  本文已影响0人  MetaAgile

git 的log提供了一个很好的维护版本的机制,类似一个回滚段,为用户提供一个撤销的单位


撤销working directory
>  git checkout -- [file] #上一版本
#git checkout 命令 和 git reset 类似,除了它会更新 working directory, 
#而不是 staged snapshot 
> git checkout HEAD~n/[commit id]#通过n或者commit hash指定版本

撤销staged snapshot
撤销working directory+staged snapshot

> git reset --hard HEAD #重置为上一版本状态,为commit层次操作


Sum:
在File层次上的操作:
  -git reset 指向stage snapshot
  -git checkout 指向working directory
在commit层次的操作:
  -git checkout 指向分支切换
  -git reset 指向[staged snapshot|staged snapshot+working directory]

参考地址

上一篇 下一篇

猜你喜欢

热点阅读