可以在此处找到有关不同方式的完整分析器:
What is HEAD and to checkout specpfic commit ore reset the repository
git checkout
git checkout
git checkout <commit_id>
git checkout -b <new branch> <commit_id>
git checkout HEAD~X // x is the number of commits t go back
这将签出指向所需提交的新分支。
此命令将检出给定的提交。
此时您可以创建一个分支并从这一点开始工作。
# Checkout a given commit.
# Doing so will result in a `detached HEAD` which mean that the `HEAD`
# is not pointing to the latest so you will need to checkout branch
#in order to be able to update the code.
git checkout <commit-id>
# create a new branch forked to the given commit
git checkout -b <branch name>
git reset HEAD --hard <commit_id>
“移动”你的头回到所需的提交。
# This will destroy any local modifications.
# Don't do it if you have uncommitted work you want to keep.
git reset --hard 0d1d7fc32
如何查看不影响当前分支的特定提交?
来自 git v2.5
git worktree add <new_path>
git worktree 将创建 2 个相互独立的工作文件夹,同时指向同一个存储库。
这将允许您对 enw 工作树上的任何实验进行操作,而不会对存储库本身产生任何影响。
这是一个关于如何创建新工作树及其结果的示例: