I forgot to merge a hotfix branch to my develop branch. Can I recover it after it's been deleted?

时间:2019-01-18 18:45:27

标签: git

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.

2 个答案:

答案 0 :(得分:0)

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>. 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

答案 1 :(得分:0)

did you delete the branch only locally ? ie: git branch -d <branch> or globally ie 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>

then merge that branch into the develop branch?