您的位置:首页 > 运维架构 > Shell

git reset

2016-07-26 09:23 495 查看
下面总结一下git reset的各个选项吧:
1 git reset –soft 只撤销commit,保留working tree和index file。
2 git reset –hard 撤销commit、index file和working tree,即撤销销毁最近一次的commit
3 git reset –mixed 撤销commit和index file,保留working tree
4 git reset和git reset –mixed完全一样
5 git reset –用于删除登记在index file里的某个文件。

git revert 和 git reset的区别 
1. git revert是用一次新的commit来回滚之前的commit,git reset是直接删除指定的commit。 
2. 在回滚这一操作上看,效果差不多。但是在日后继续merge以前的老版本时有区别。因为git revert是用一次逆向的commit“中和”之前的提交,因此日后合并老的branch时,导致这部分改变不会再次出现,但是git reset是之间把某些commit在某个branch上删除,因而和老的branch再次merge时,这些被回滚的commit应该还会被引入。 
3. git reset 是把HEAD向后移动了一下,而git revert是HEAD继续前进,只是新的commit的内容和要revert的内容正好相反,能够抵消要被revert的内容。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git shell unix