Naf*_*Kay 49 git version-control branching-and-merging
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.
Run Code Online (Sandbox Code Playgroud)
现在我已经搞砸了,如何将该提交与我当前的分支相关联?我对创建一个全新的分支并不感兴趣,我只想将该提交提取到我的分支中issue2
.
Ada*_*ruk 87
你可以,git cherry-pick bada553d
如果它只是一个提交.
您还可以使用reflog引用您曾经去过的任何地方:
git reflog
Run Code Online (Sandbox Code Playgroud)
然后使用其中一个提交:
git checkout -b temp HEAD@{3}
Run Code Online (Sandbox Code Playgroud)
检查并从当前提交3"次"之前创建分支临时值.这是你过去的面包屑.
小智 20
如果您只想将该提交与当前分支相关联,您可以简单地执行此操作
运行此命令以使用该提交创建一个新分支
git branch temp {commit's SHA}
然后简单地将此提交与您当前的分支合并
git merge temp
现在只需删除我们创建的临时新分支
git branch -d temp
归档时间: |
|
查看次数: |
25333 次 |
最近记录: |