使用非文本文件/大型项目的 Git 与 SVN

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5771492/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:22:32  来源:igfitidea点击:

Git vs SVN With Non Text Files / Large Projects

gitversion-control

提问by ryanzec

I have been learning Git the past weeks or so and I really like the way it works in comparison to SVN. The main reason I am looking to fully switch to it is the fact that merging is supposedly a lot easier with few conflicts and the fact I can commit locally. This promotes the use of many branches (like a branch per ticket/issue/task/etc..) and also promote many commits. I only use branches if I need to in SVN (since merges often produces conflicts) and I only commit when I am 100% sure the issue is fix (instead of incremental commits, which would be nicer).

过去几周我一直在学习 Git,与 SVN 相比,我真的很喜欢它的工作方式。我希望完全切换到它的主要原因是合并应该更容易,冲突很少,而且我可以在本地提交。这促进了许多分支的使用(例如每个票证/问题/任务/等的分支)并促进了许多提交。我只在 SVN 中需要时才使用分支(因为合并经常会产生冲突)并且我只在我 100% 确定问题已修复时才提交(而不是增量提交,这会更好)。

Now, one concern I have about git as I have been reading it is about non text files/large projects. For example I am working on a game project currently controlled in SVN. Now with a game project, there are going to be a lot of non text files like art, sound, and other binary files and some of the files can get pretty big. How well does git handle non text file / large binary files? What are some of the considerations I have to keep in mind if I want to port over such a project to git?

现在,当我阅读 git 时,我对 git 的一个担忧是关于非文本文件/大型项目。例如,我正在开发一个目前在 SVN 中控制的游戏项目。现在对于一个游戏项目,将会有很多非文本文件,如艺术、声音和其他二进制文件,其中一些文件可能会变得非常大。git 处理非文本文件/大型二进制文件的效果如何?如果我想将这样的项目移植到 git,我必须记住哪些注意事项?

回答by poke

One of the big differences in how Git stores data compared to other version control systems is that Git stores the file content completely as a single object. That means that every version of every file exists as a complete file in your repository (it's very compressed though). So while other VCS store the differences/deltas between two versions, and as such handles binary and text files differently (as binary files are not that diff-able), Git just handles all of them identical.

与其他版本控制系统相比,Git 存储数据的方式的一大差异是 Git 将文件内容完全存储为单个对象。这意味着每个文件的每个版本都作为一个完整的文件存在于您的存储库中(尽管它非常压缩)。因此,虽然其他 VCS 存储两个版本之间的差异/增量,并且因此以不同的方式处理二进制和文本文件(因为二进制文件不具有差异性),但 Git 只是处理所有相同的文件。

As such, working with binary files in Git is not different to using any other file type. You just need to keep in mind that versioning very large files is going to increase your repository size a lot (as every single version of that large file is stored as it is, even if the actual, binary change was small). Git's compression however works wonders and makes you not notice this usually. Especially if you are only talking about a program's assets, you probably won't have any difficulties.

因此,在 Git 中使用二进制文件与使用任何其他文件类型没有什么不同。您只需要记住,对非常大的文件进行版本控制会大大增加您的存储库大小(因为该大文件的每个版本都按原样存储,即使实际的二进制更改很小)。然而,Git 的压缩创造了奇迹,并且通常不会让您注意到这一点。特别是如果您只谈论程序的资产,您可能不会遇到任何困难。

回答by manojlds

Adding @poke's answer

添加@poke 的答案

I am an avid Git user these days, but having worked in a huge project where there were lots of binary files - mostly zips - to be handled - I found SVN to be more efficient than Git. The size of the Git repo got bloated up in no time while the size of a similar SVN repository did not vary much. Cloning such a huge Git repo, especially across geographically distributed places was a nightmare. Git also doesn't have a partial clone feature, something that we do in SVN all the time - checkout just a particular folder. There is partial checkout in git, but you still have to clone the entire repo.

这些天我是一个狂热的 Git 用户,但在一个巨大的项目中工作过,其中有很多二进制文件 - 主要是 zip - 需要处理 - 我发现 SVN 比 Git 更有效。Git 存储库的大小很快就膨胀了,而类似的 SVN 存储库的大小并没有太大变化。克隆如此庞大的 Git 存储库,尤其是跨地理分布的地方,简直是一场噩梦。Git 也没有部分克隆功能,这是我们一直在 SVN 中所做的 - 仅检出特定文件夹。在 git 中有部分 checkout,但你仍然需要克隆整个 repo。

Note that whether or not a file is binary does not affect the amount of repository space used to store changes to that file, nor does it affect the amount of traffic between client and server. For storage and transmission purposes, Subversion uses a diffing method that works equally well on binary and text files; this is completely unrelated to the diffing method used by the 'svn diff' command.

请注意,文件是否为二进制文件不会影响用于存储对该文件的更改的存储库空间量,也不会影响客户端和服务器之间的流量。出于存储和传输的目的,Subversion 使用了一种对二进制文件和文本文件同样有效的差异方法;这与 'svn diff' 命令使用的差异方法完全无关。

http://subversion.apache.org/faq.html#binary-files

http://subversion.apache.org/faq.html#binary-files

Given SVN's mature sys admin tools ( Git also has improved over the years, but I feel SVN still has the edge in this aspect ) I think it will be wise to have a SVN server with probably git-svn repo for local development.

鉴于 SVN 成熟的系统管理工具(Git 多年来也有所改进,但我觉得 SVN 在这方面仍然具有优势)我认为拥有一个可能带有 git-svn repo 的 SVN 服务器进行本地开发是明智的。

There is something call git-bigfiles - which is a fork of git. Not sure how mature it is. You can evaluvate it. But the fact that it exists, shows Git is not necessarily good at handling large files.

有一种叫做 git-bigfiles 的东西——它是 git 的一个分支。不知道成熟到什么程度。你可以评价一下。但它存在的事实表明 Git 不一定擅长处理大文件。

回答by manojlds

Other answers have addressed the choices here, but there is also the possibility of using SVN for the binary files (if they will change a lot), and git for everything else. During the build phase, you can use scripts to fetch the binary resource from svn.

其他答案已经解决了这里的选择,但也有可能将 SVN 用于二进制文件(如果它们会发生很大变化),而 git 用于其他所有文件。在构建阶段,您可以使用脚本从 svn 获取二进制资源。

回答by ALoR

git handles perfectly the binary files. You just have to keep in mind that all the versions of the binary file are kept locally. If a binary file (let's say an image) changes frequently, you will end up filling up your local space with all the version of the image.

git 可以完美地处理二进制文件。您只需要记住,二进制文件的所有版本都保存在本地。如果一个二进制文件(比方说一个图像)经常改变,你最终会用所有版本的图像填满你的本地空间。