我在一个月前删除了当地分行的工作。我不记得分支名称的名称。
有没有办法显示我所拥有的所有本地分支的名称git reflog这似乎没有任何用处,它只显示大约20个提交,而没有关于它们在本地分支上或它的名字。
答案 0 :(得分:1)
有没有办法显示所有本地分支的名称
要查看当前的本地分支机构:
git branch
如果您没有将本地与任何其他分支合并,如果您将其删除并且git reflog
对您没有帮助,您可以随时使用git fsck --lost-found
打印悬空提交列表(提交无法从任何其他提交/分支访问。)
git fsck --lost-found
强> <强>
--lost-found
强>根据类型将悬空物体写入
.git/lost-found/commit/
或.git/lost-found/other/
。如果对象是blob,则将内容写入文件,而不是其对象名称。
一旦你有了这些提交,你可以使用:git show <SHA-1>
将它们打印出来,一旦你看到一个树搜索根提交,你现在可以恢复它。
# find out all dangling (loos) objects
git fsck --lost-found
# find out the desired root tree using the git cat-file or git show
# Search for tree objects
git cat-file -t <SHA-1>
# once a tree was found print its content
git cat-file -p <SHA-1>
# OR
# again print it content in different way
git show <SHA-1>
# once you found your lost tree - recover it
git checkout <branch_name> <SHA-1>
git fsck --full --no-reflogs --unreachable --lost-found
# --full = Checkout all object in other locations
(read doc to find all about it)
# --no-reflogs = This option is meant only to search for commits that used
to be in a ref, but now aren’t, but are still in that
corresponding reflog.
# --unreachable= Print out objects that exist but that aren’t reachable from
any of the reference nodes.