【问题标题】:Git I changed the HEAD by mistake, and don't know what to doGit我误改了HEAD,不知道怎么办
【发布时间】:2021-06-27 16:35:57
【问题描述】:

我的项目有 2 个分支 mainfeature1。我合并了它们,然后我尝试删除feature1 我以为命令是git checkout -d feature1,但它不是,现在它说HEAD is now at 71bgr8p (My latest commit message)。它表明我在一个分支((71bgr8p...))。当我输入git branch 时,它表示我当前所在的分支是HEAD detached at refs/heads/feature1

如何撤消此操作?

【问题讨论】:

    标签: git github merge version-control branch


    【解决方案1】:

    您当前处于分离的 HEAD 状态。修复很简单,只需检查另一个分支,例如返回main 分支:

    git checkout main
    

    至于删除feature1分支,使用如下:

    git branch -d feature1        # to delete the local branch
    git push -d origin feature 1  # to delete the remote branch
    

    【讨论】:

      猜你喜欢
      • 2015-12-31
      • 1970-01-01
      • 2021-06-21
      • 1970-01-01
      • 2012-02-01
      • 1970-01-01
      • 2013-11-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多