gpt4 book ai didi

git - 如何在特定提交之前 git checkout 一次提交

转载 作者:行者123 更新时间:2023-12-03 23:54:01 25 4
gpt4 key购买 nike

在浏览了 github 问题后,我发现了一个可能导致破坏代码的提交,我想通过执行以下操作来确认这种怀疑:
git checkout --one-prior f1962b3cc771184a471e1350fa280d80d5fdd09d

最佳答案

干得好:

git checkout f1962b3cc771184a471e1350fa280d80d5fdd09d^

请注意 ^在末尾。这意味着落后一个修订版。

例如,这将落后 5 个修订版:
git checkout f1962b3cc771184a471e1350fa280d80d5fdd09d^^^^^

... 相当于:
git checkout f1962b3cc771184a471e1350fa280d80d5fdd09d~5

顺便说一句,当您这样做时,您将处于分离的 HEAD 状态。输出解释了这一点,非常有趣,值得一读:

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

    git checkout -b new_branch_name

关于git - 如何在特定提交之前 git checkout 一次提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20455980/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com