Git GUI 所指的“松散对象”是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5709687/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are the "loose objects" that the Git GUI refers to?
提问by oxo
When I open the Git GUI, I get a popup message that refers to loose objects
. I did git gc
and that removed the message.
当我打开Git GUI 时,我收到一条弹出消息,其中引用了loose objects
. 我做到了,git gc
并删除了该消息。
What are loose objects
and how could I prevent this from occurring again?
什么是loose objects
以及如何防止这种情况再次发生?
采纳答案by manojlds
An object (blobs, trees, and commits) with SHA say - 810cae53e0f622d6804f063c04a83dbc3a11b7ca will be stored at
具有 SHA 的对象(blob、trees 和 commits)说 - 810cae53e0f622d6804f063c04a83dbc3a11b7ca 将存储在
.git/objects/81/0cae53e0f622d6804f063c04a83dbc3a11b7ca
( the split in first two characters to improve performance of the File system as now not all the objects are stored in the same directory)
(拆分前两个字符以提高文件系统的性能,因为现在并非所有对象都存储在同一目录中)
Objects stored as above are referred to as Loose objects.
如上存储的对象称为松散对象。
When you start up with your repo, you mostly have loose objects. As the number goes high, it becomes inefficient and they are stored in a pack file. Such objects are called packed objects.
当你开始使用你的 repo 时,你大部分都是松散的对象。随着数字变高,它变得效率低下,它们被存储在一个包文件中。此类对象称为打包对象。
git gc
is what you run to pack objects (Usually loose objects that are not needed and few weeks old are also removed and with --prune=<date>
option you can force remove loose objects that are no longer needed. Like when you amend a commit. The old commit object is no longer needed. )
是你用来打包对象的东西(通常不需要的松散对象和几周前的对象也会被删除,并且可以--prune=<date>
选择强制删除不再需要的松散对象。就像你修改提交时一样。旧的提交对象是没有需要更长的时间。)
回答by Mohamed Mansour
The Git Book explains it pretty well: https://git-scm.com/book/en/v2/Git-Internals-Packfiles
Git Book 很好地解释了它:https: //git-scm.com/book/en/v2/Git-Internals-Packfiles
Loose objects are the simpler format. It is simply the compressed data stored in a single file on disk. Every object written to a seperate file.
松散对象是更简单的格式。它只是存储在磁盘上单个文件中的压缩数据。每个对象都写入一个单独的文件。