gpt4 book ai didi

git - Git 从不删除任何信息吗?

转载 作者:太空狗 更新时间:2023-10-29 13:33:50 25 4
gpt4 key购买 nike

我看过这篇文章: http://jenkins-ci.org/content/summary-report-git-repository-disruption-incident-nov-10th

它描述了一个事件,其中用户意外地从存储库的过时状态触发了 git push --force

当然,这需要进行一些清理以恢复原始状态分支。但由于 Git 从不删除信息,据我所知,此清理过程始终是可能的。

因此,即使您 rebase 、push --force(以及其他可能重写历史的操作)原始提交仍然存在,只是需要找到它们,对吧?

简而言之,git中真正删除数据的任何(破坏性)操作是什么?

最佳答案

无法通过任何引用访问的提交最终将被删除,其中包括引用日志。发生这种情况的默认时间段非常保守。您可以使用多种选项通过 git config 进行调整。请参阅下面的一些特定选项。

很多人(包括我自己)会建议您设置接收 Hook 以拒绝非快进 merge ,这在很大程度上会使这个问题变得毫无实际意义(在服务器上,个人仍然可能会丢失未推送的本地工作)。

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>.

关于git - Git 从不删除任何信息吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26448898/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com