git - 为什么我的 git reflog 不返回到克隆

标签 git git-reflog reflog

我有一个关于 git reflog 的问题:

在我的项目开始时,当我执行 git reflog 时,我能够看到直到我最初的 git clone 命令的所有步骤。

今天,git reflog 不再返回到 git clone 命令。

更准确地说,git reflog 返回 4143 行,最后几行被截断:

$ git reflog
6146d34 HEAD@{0}: checkout: moving from feature/cluster to feature/config
[...]
cb14a86 HEAD@{4140}: checkout: moving from master to demo/20170529
b2ef8d6 HEAD@{4141}: checkout: moving from master to demo/20170529
b2ef8d6 
$ 

谁能解释一下为什么?

有没有办法获取整个 reflog?

非常感谢,

朱利安

最佳答案

正如其他人所指出的,reflogs 是临时设计的。我会添加这个:

您可以调整影响 reflog 条目保留时间的配置设置,但即便如此您也应该将它们视为临时的,因为 reflog 严格是本地的——也就是说,它们不会通过推送(或来自获取/pull 远程)而是跟踪 refs 的历史仅在本地克隆。因此,如果您不得不替换本地存储库,那么无论您的配置如何设置,您都会丢失所有 reflog。

更新 以回应评论中的后续问题:相关设置(记录在此处:https://git-scm.com/docs/git-config)是

gc.reflogExpire
gc.<pattern>.reflogExpire
gc.reflogExpireUnreachable
gc.<pattern>.reflogExpireUnreachable

关于git - 为什么我的 git reflog 不返回到克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45959064/

相关文章:

git - 恢复 - git reset --hard HEAD^

git - 获取 HEAD 最后指向的引用名称的最可靠方法是什么?

git - 当对 git 存储库进行本地更新时,如何显示日期?

git - 在运行脚本之前使用 Github.com 检查 ssh

git - 如何让 git add -p 接受击键而不等我按 Enter 键?

git - 列出压缩的提交

macos - Git:删除当前分支并丢失 reflog

git - 解决git冲突的问题

git - 无法推送到基于文件的存储库

git - 未出现在任何分支中但在 "git show"中可用的提交发生了什么