赞
踩
1. git reset 与它的三个参数
格式:git reset 命令格式为git reset [--soft | --mixed | --hard] [<commitId>]
--hard: 版本回退指定的commit , 同时清空了 index(暂存区)和 working(工作区),所以该操作可能会丢失本地的修改。
--soft:版本回退指定的commit , 原 index(暂存区)和 working(工作区)的内容不变, 而回退的 commit 则处于 index(暂存区) 中,可以直接使用 git commit -m '注释' 进行提交。
--mixed: 版本回退指定的commit, 原 working(工作区)的内容不变, index(暂存区) 内容的状态回退到 working(工作区)中, 而回退的 commit 也处于working(工作区)中,若要提交,需先 git add。
2. git reflog
git log :
命令可以显示当前分支所有提交过的版本信息,不包括已经被删除的 commit 记录和reset的操作。(注意: 只是当前分支操作的信息)。
git reflog:
命令可以查看所有分支的所有操作记录信息(包括已经被删除的 commit 记录和 reset 的操作)
3. git reset 与 git reflog 的联合使用
使用 git reset 进行版本回退之后,发现回退错了,需要还原本次的回滚,可是这个时候使用 git log 已经查询不到 reset 的commit_id了,此时可以使用 git reflog 命令。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。