Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第7章 Git重置 #45

Open
GH1995 opened this issue Jan 13, 2020 · 2 comments
Open

第7章 Git重置 #45

GH1995 opened this issue Jan 13, 2020 · 2 comments
Labels

Comments

@GH1995
Copy link
Owner

GH1995 commented Jan 13, 2020

分支游标 master探秘

Git提供了 git reset命令,可以将“游标”指向任意一个存在的提交ID。

git reset --hard HEAD^
@GH1995 GH1995 added the git label Jan 13, 2020
@GH1995
Copy link
Owner Author

GH1995 commented Jan 13, 2020

reflog挽救错误的重置

git reflog show master | head -5

重置master 为两次改变之前的值

git reset --hard master@{2}

@GH1995
Copy link
Owner Author

GH1995 commented Feb 6, 2020

深入了解 git reset命令

用法一:git reset [-q] [<commit>] [--] <paths> ...

第一种用法(包含了路径<paths>的用法)不会重置引用,更不会改变工作区,而是用指定提交状态(<commit>)下的文件(<paths>)替换掉暂存区中的文件。例如命令 git reset HEAD <paths>相当于取消之前执行的 git add <paths>命令时改变的暂存区。

用法二:git reset [--soft | --mixed | --hard | --merge | --keep] [-q] [< commit>]

第二种用法(不使用路径<paths>的用法)则会重置引用。根据不同的选项,可以对暂存区或工作区进行重置。

命令:git reset --hard HEAD
彻底撤销最近的提交。引用回退到前一次,而且工作区和暂存区都会回退到上一次提交的状态。自上一次以来的提交全部丢失。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant