【问题标题】:What is the git equivalent to hg update to get a specific historical version? [duplicate]获取特定历史版本的 git 等效于 hg update 是什么? [复制]
【发布时间】:2019-11-25 08:28:35
【问题描述】:

我以为是git reset --hard,但除了恢复到旧版本之外,自从我上次推送到服务器后,它删除了我所有的本地更改!现在我必须重做一个小时的工作......感谢上帝,我昨晚努力了,否则我会被搞砸的!

【问题讨论】:

    标签: git


    【解决方案1】:

    使用git checkout -b new_branch_name your_commit_hash

    如果您不使用-b new_branch_name,它将最终处于分离的 HEAD 状态。

    【讨论】:

    • 我为什么要创建一个新分支?我只想加载旧版本的代码来比较它与最新版本的行为;我不打算进行额外的更改。顺便说一句,我发现一篇文章告诉我如何从 git reset 中恢复 - 我必须使用 git reflog 找到最新的“好”提交(它实际上并没有被删除!)然后 git reset 到那个特定的提交 ID 和现在一切都回来了! :D
    • 是的,然后简单地忽略 -b 标志并使用git checkout your_commit_hash
    猜你喜欢
    • 2011-11-29
    • 2019-04-15
    • 1970-01-01
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 2017-07-22
    • 1970-01-01
    • 2020-05-16
    相关资源
    最近更新 更多