Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git从不删除任何信息吗?_Git_Garbage Collection_Object Oriented Database - Fatal编程技术网

Git从不删除任何信息吗?

Git从不删除任何信息吗?,git,garbage-collection,object-oriented-database,Git,Garbage Collection,Object Oriented Database,我读过这篇文章: 它描述了一个事件,其中用户从存储库的过时状态意外触发了一个git push--force 当然,这需要一些清理来恢复原始状态分支。但据我所知,由于Git从不删除信息,所以清理过程始终是可能的 因此,即使您重新基址、推送-强制(以及其他可能重写历史的操作),原始提交仍然存在,它们只是需要找到,对吗 简而言之,git中的任何(破坏性)操作是否确实删除了数据?通过任何引用都无法访问的提交最终将被删除,其中包括reflog。发生这种情况的默认时间段相当保守。有几个选项可用于调整此设置

我读过这篇文章:

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

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

因此,即使您重新基址、推送-强制(以及其他可能重写历史的操作),原始提交仍然存在,它们只是需要找到,对吗


简而言之,git中的任何(破坏性)操作是否确实删除了数据?

通过任何引用都无法访问的提交最终将被删除,其中包括reflog。发生这种情况的默认时间段相当保守。有几个选项可用于调整此设置,具体选项请参见下文

很多人(包括我自己)会建议你设置你的接收钩子来拒绝非快进合并,这在很大程度上会使这个问题变得无关紧要(在服务器上,个人仍然可能丢失未推送的本地工作)

gc.auto
当存储库中的松散对象大约超过这么多时,git gc--auto将打包它们。某些命令使用此命令不时执行轻型垃圾收集。默认值为6700。将此设置为0将禁用它。
prueexpire
当git gc运行时,它将调用prune--expire-2.weeks.ago。使用此配置变量覆盖宽限期。值“now”可用于禁用此宽限期,并始终立即修剪无法访问的对象。
gc.reflogexpire
gc..reflogexpire
git reflog expire删除比此时间早的reflog条目;默认为90天。在“中间”(例如“REFS/STASH”)中,设置只适用于匹配的参考文献。
gc.reflogexpireunreachable
gc..refrogexpireunreable
git reflog expire将删除早于此时间的reflog条目,并且当前tip无法访问这些条目;默认为30天。在“中间”(例如“REFS/STASH”)中,设置只适用于匹配的参考文献。

Git最终会删除一些东西。它自动垃圾收集每“5000个对象”。我不确定这是否意味着5000次提交,或者它是否引用了其他内容。虽然当一个人从旧版本的回购协议中强行推出时,可能会令人恼火,但撤销事情的方法还是有的。根据您是否删除错误的推送或还原,git历史记录中会有垃圾,但git最终会清理

好吧,如果你gc+修剪之后,它就会消失。或者等等。是的,在提交--amend(请参阅)、重设基础、强制推送等之后无法访问的对象在repo的对象数据库中保留一段时间。虽然这些对象最终会被垃圾回收,但默认情况下,此过程不是中间过程,并给您一些时间来修复混乱。此外,只要可以从reflog访问对象,就不会删除这些对象。reflog是您可以用来修复错误的安全网。
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>.