我看过这篇文章: http://jenkins-ci.org/content/summary-report-git-repository-disruption-incident-nov-10th
描述了用户从存储库的过期状态意外触发git push --force
的事件。
现在当然这需要一些清理来恢复原始状态分支。但是,由于Git从不删除信息,因为我理解这种清理过程总是可行的。
所以,即使你重新定义,推入-force(以及其他可能重写历史记录的操作)原始提交仍然存在,他们只需要找到它们吗?
简而言之,git中的任何(破坏性)操作实际上都会删除数据吗?
答案 0 :(得分:5)
通过任何引用无法访问的提交将最终删除,其中包括reflog。这种情况发生的默认时间段非常保守。您可以通过git config使用几个选项来调整此选项。有关具体选项,请参阅下文。
很多人(包括我自己)会建议你设置你的接收挂钩以拒绝非快进合并,这在很大程度上会使这个问题没有实际意义(在服务器上,个人仍可能失去未经推迟的本地工作)。
gc.auto
When there are approximately more than this many loose objects in the repository, git gc --auto will pack them. Some Porcelain commands use this command to perform a light-weight garbage collection from time to time. The default value is 6700. Setting this to 0 disables it.
gc.pruneexpire
When git gc is run, it will call prune --expire 2.weeks.ago. Override the grace period with this config variable. The value "now" may be used to disable this grace period and always prune unreachable objects immediately.
gc.reflogexpire
gc.<pattern>.reflogexpire
git reflog expire removes reflog entries older than this time; defaults to 90 days. With "<pattern>" (e.g. "refs/stash") in the middle the setting applies only to the refs that match the <pattern>.
gc.reflogexpireunreachable
gc.<ref>.reflogexpireunreachable
git reflog expire removes reflog entries older than this time and are not reachable from the current tip; defaults to 30 days. With "<pattern>" (e.g. "refs/stash") in the middle, the setting applies only to the refs that match the <pattern>.
答案 1 :(得分:0)
Git最终删除了一些东西。它自动垃圾收集每个“5000个对象”。我不确定这是否意味着5000次提交或者是否引用其他内容。有一些方法可以解开东西,虽然当一个人从旧版本的回购推出时可能会令人讨厌。根据你是否删除坏推或恢复,你的git历史中会有垃圾,但git最终会清理。