[英]I forgot to merge a hotfix branch to my develop branch. Can I recover it after it's been deleted?
I made the mistake of merging a hotfix branch with master and then deleting the branch before merging it with develop . 我做了合并与主 修补程序分支,然后合并它与之前开发删除分支的错误。 Is it possible to recover the hotfix branch so I can do the missed merge?
是否可以恢复修补程序分支,以便我可以进行错过的合并? Or would something like a cherry-pick work just the same?
还是像采摘樱桃一样起作用?
Thanks. 谢谢。
The commit should still be available on the machine you deleted the branch from. 删除分支所在的计算机上的提交仍应可用。
If you can remember the commit hash, it's really easy -- just do a git checkout <commit hash>
. 如果您还记得提交哈希,那真的很容易-只需执行
git checkout <commit hash>
。 Then you can point a branch at the commit. 然后,您可以将分支指向提交。
If you don't remember the commit hash, things are a bit more difficult, since you will need to find a dangling commit. 如果您不记得提交哈希,那么事情会变得有些困难,因为您将需要找到一个悬空的提交。
This blog post gives a quick overview on how to do that: http://gitready.com/advanced/2009/01/17/restoring-lost-commits.html 这篇博客文章提供了有关该操作方法的快速概述: http : //gitready.com/advanced/2009/01/17/restoring-lost-commits.html
did you delete the branch only locally ? 您是否仅在本地删除分支? ie:
git branch -d <branch>
or globally ie git branch -D <branhc>
? 即:
git branch -d <branch>
或全局即git branch -D <branhc>
吗?
if the branch is still available on remote you can pull it back down, if you deleted it from both local you can go back to the commit in your master branch where you merged in the hotfix and create a new branch from that commit hash git checkout -b <commit hash>
如果分支在远程仍然可用,则可以将其拉回;如果从两个本地都删除了分支,则可以返回到主分支中的提交,在此分支中合并了此修补程序,并从该提交中创建新分支
git checkout -b <commit hash>
then merge that branch into the develop branch? 然后合并该分支到开发分支?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.