EGit 再次来袭。我犯了一个错误,试图切换到 EGit 中的另一个分支,但它不知何故搞砸了,没有检查出任何分支。然后我提交了这个非分支,然后当我意识到我没有跟踪正确的分支时,我运行了以下命令:
$ git checkout issue2
Warning: you are leaving 1 commit behind, not connected to any of your branches:
bada553d My commit message
If you want to keep them by creating a new branch, this may be a good time to do so with:
git branch new_branch_name ....
Branch issue2 set up to track remote branch issue2 from origin.
Switched to a new branch issue2.
既然我搞砸了,我该如何将那个提交与我当前的分支相关联?我对创建一个全新的分支不感兴趣,我只想将该提交 pull 入我的分支 issue2
。
最佳答案
如果只是一次提交,您可以 git cherry-pick bada553d
。
您还可以使用 reflog 引用您去过的任何地方:
git reflog
然后使用其中一个提交:
git checkout -b temp HEAD@{3}
从当前提交 3“次”之前的位置 checkout 并创建一个临时分支。它是您过去所在位置的面包屑。
关于git - 警告 : you are leaving 1 commit behind, 未连接到您的任何分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14365736/