有人可以解释Git中使用的内容跟踪和其他SCM中使用的文件跟踪之间的区别 [英] Can someone explain the distinction between content tracking used in Git and file tracking used in other SCMs

查看:104
本文介绍了有人可以解释Git中使用的内容跟踪和其他SCM中使用的文件跟踪之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在一直在使用Git,并喜欢它允许的工作流的功能和灵活性。对于我来说,提前和经常提交的能力对我来说是一项巨大的交易,并且非常适合我的工作方式。

我曾经听过很多次提到的Git的一个特性,但我的脑海里还有一个事实,那就是它跟踪的是内容而不是文件历史,它应该能够处理重命名和移动文件。

?与SVN相比,我没有注意到这方面有什么特别之处。我缺少什么?

解决方案

Git商店分别为三段数据


  • 内容存储在blob对象

  • 历史记录存储在提交对象中
  • 结构存储在树对象中


这样做的结果是,如果在几个文件中有相同的数据,git只需要存储一次,因为结构(包含目录和文件)只需指向一个内容对象。

同样,如果一个文件的版本不一样,git只需要存储一次该文件。多个历史记录对象指向相同的内容。



用户可见的一些好处是: git blame非常擅长看到代码跨文件移动,特别是如果你告诉它看起来很难与 git blame -C 。这也是为什么git非常紧凑和快速的原因,结构非常简单,走路很便宜,不会重复。

缺点之一是git不存储文件副本和重命名,它只是猜测,有时它是错误的。



这个博客文章提供了一个很好的消化,但仍然详细讨论什么内容跟踪购买混帐。如果您想了解更多信息,可以观看Linus的Google技术讲座或< a href =https://git.wiki.kernel.org/index.php/LinusTalk200705Transcript =noreferrer>阅读记录。


I've been using Git for a while now and love the features and flexibility in workflow it allows. The ability to commit early and often is a huge deal for me and really fits into my way of working.

One feature of Git I've heard mentioned many times but have yet to get my head around is the fact that it tracks content rather than file history which supposed makes dealing with renaming and moving files much better.

Can someone explain why this is? I haven't noticed anything special in this regard compared to SVN. What am I missing?

解决方案

Git stores three pieces of data separately:

  • content is stored in blob objects
  • history is stored in commit objects
  • structure is stored in tree objects

A consequence of this is that if you have the same data in several files, git only has to store it once, because the structure (which contains directories and files) only has to point at one content object.

Similarly, if a file does not change from version to version, git only has to store that file once. Multiple history objects point to the same content.

Some of the user visible benefits is that git blame is very good at seeing code move across files especially if you tell it to look real hard with git blame -C. It's also some of why git is so compact and fast, the structure is very simple, very cheap to walk and doesn't repeat itself.

One of the downsides is that git doesn't store file copies and renames, it just guesses, and sometimes it's wrong.

This blog entry provides a decently well digested but still detailed discussion of what content tracking buys git. If you want to know more, you can watch Linus' Google Tech Talk on Git or read the transcript.

这篇关于有人可以解释Git中使用的内容跟踪和其他SCM中使用的文件跟踪之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆