Yes, you should be able to do git reflog
and find the SHA1 for the commit at the tip of your deleted branch, then just git checkout [sha]
.
(是的,您应该能够执行git reflog
并在已删除分支的尖端找到提交的SHA1,然后只需执行git checkout [sha]
。)
And once you're at that commit, you can just git checkout -b [branchname]
to recreate the branch from there. (一旦完成该提交,就可以git checkout -b [branchname]
从那里重新创建分支。)
Credit to @Cascabel for this condensed/one-liner version.
(感谢此压缩/单线版本的@Cascabel。)
You can do it in one step:
(您可以一步完成:)
git checkout -b <branch> <sha>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…