Recover deleted branch in Git [duplicate]

六月ゝ 毕业季﹏ 提交于 2019-11-28 05:22:57

Create a list of all dangling or unreachable commits.

git fsck --full --no-reflogs --unreachable --lost-found

Print a list of commit messages for all commits in the lost and found.

ls -1 .git/lost-found/commit/ | xargs -n 1 git log -n 1 --pretty=oneline

Find your missing commit through the process of manual inspection (i.e. reading). Create a new branch with the missing commit as the branch head.

git checkout -b branch-name SHA

Having got the potential sha1 for the last tip of branch demo, use gitk sha1 to actually browse the commit's history to check you have the right one.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!