How to get the removed branches in git
I merge my all of the branches to a wrong branch and deleted all of the branches. Is it possible to recover all of these branch and unmerge them. I also resolv开发者_运维百科ed conflict at the time of merging
Use a tool like gitk --all
to find the commits that your branches were at before the merge.
Once you've got the commit's SHA1s, you can re-create the branches with something like:
git checkout <the sha1> -b <the old branch name>
Or simply:
git branch <the old branch name> <the sha1>
Or right-click on the relevant commit in gitk
and use the Create new branch
menu.
Repeat for all your old branch names. The go back to your incorrectly merged branch and revert the merge commit, or use some history rewriting to make it "go away". (Be very careful with that second option, it's not a good idea if you've already published that merge.)
精彩评论