# 查看文件内容
$ cat .\test.txt
abc
oops
# 提交到版本库
$ git commit -a -m "Oops,an error committed"
# 查看提交日志
$ git hist
* 739560c 2023-05-05 | Oops,an error committed (HEAD -> master) [aku]
* 1ca1854 2023-05-05 | Revert "Added 123 to the test.txt" [aku]
* 375f4fe 2023-05-05 | Added 123 to the test.txt [aku]
* d7f681f 2023-05-05 | Added abc to the test.txt (tag: v1) [aku]
* 01b8702 2023-05-05 | Add first file (tag: v1-beta) [aku]
# 打上标签 oops
git tag oops
$ cat .\test.txt
abc
oops
$ git reset --hard v1
$ git hist
* d7f681f 2023-05-05 | Added abc to the test.txt (HEAD -> master, tag: v1) [aku]
* 01b8702 2023-05-05 | Add first file (tag: v1-beta) [aku]
$ cat .\test.txt
abc
$ git hist --all
* 2dd1257 2023-05-04 | Oops,an error committed (tag: oops) [aku]
* bcd7c90 2023-05-04 | Added abc (HEAD -> master, tag: v1) [aku]
* 05ade05 2023-05-04 | Add first file (tag: v1-beta) [aku]
本地分支的重置通常是安全的。任何“意外”情况通常可以通过使用所需提交再次重置来恢复。但是,如果该分支在远程存储库上共享,则重置可能会使其他共享该分支的用户感到困惑。