git-learner/notes/2.4-git_reset.md
2024-08-16 10:17:30 +02:00

694 B

2.4.1 reset

HEAD^代表版本库中的上一次提交

2.4.2 reflog

查看前五次提交的内容

tail -5 .git/logs/refs/heads/master

查看最后五次提交内容

git reflog show master | head -5

得到一个更容易记录的号码branch@{#},来用git reset --<way> branch@{#}来记录

2.4.3

git reset [-- filename] 用HEAD重置暂存区,加上filename之后只重置单个文件

  1. HEAD指向的branch更换成指定的commit ID
  2. 暂存区中的内容替换成HEAD指向的branch的目录树
  3. 把工作区替换成暂存区中的目录树

git reset --hard commit 1 2 3 git reset --soft commit 1 git reset --mixed commit 1 2