在 visual studio 中意外删除分支 git
Deleted branch unexpectedly git in visual studio
我在 visual studio 2013 年与 git 一起工作,今天我意外地删除了一个分支。现在,当我去创建分支时,它不会显示在 select 的下拉列表中并再次创建它。
按照以下步骤操作:
- 执行
git reflog
并找到您刚刚删除的分支的最后一次提交(即头部)的 SHA-1 哈希值。
- 执行
git checkout -b <SHA-1>
其中 SHA-1
对应于您在步骤 1 中找到的提交。
第 1 步:
创建所有无法访问的提交的列表。
git fsck --full --no-reflogs --unreachable --lost-found
第 2 步:
打印失物招领处所有提交的提交消息列表。
ls -1 .git/lost-found/commit/ | xargs -n 1 git log -n 1 --pretty=oneline
第 3 步:
搜索您丢失的提交。创建一个新分支,以缺少的提交作为分支头。
git checkout -b branch-name SHA
我在 visual studio 2013 年与 git 一起工作,今天我意外地删除了一个分支。现在,当我去创建分支时,它不会显示在 select 的下拉列表中并再次创建它。
按照以下步骤操作:
- 执行
git reflog
并找到您刚刚删除的分支的最后一次提交(即头部)的 SHA-1 哈希值。 - 执行
git checkout -b <SHA-1>
其中SHA-1
对应于您在步骤 1 中找到的提交。
第 1 步:
创建所有无法访问的提交的列表。
git fsck --full --no-reflogs --unreachable --lost-found
第 2 步:
打印失物招领处所有提交的提交消息列表。
ls -1 .git/lost-found/commit/ | xargs -n 1 git log -n 1 --pretty=oneline
第 3 步:
搜索您丢失的提交。创建一个新分支,以缺少的提交作为分支头。
git checkout -b branch-name SHA