使用 git 处理图像
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3618447/
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
using git for images
提问by Morten
I'm considering using GIT or our family photos. The scenario is that both me and my girlfriend uses digital cameras, upload the photos to each our own computer. But still want to organize the photos into folders for different events, and have that organization replicated between our two computers.
我正在考虑使用 GIT 或我们的家庭照片。场景是我和我的女朋友都使用数码相机,将照片上传到我们自己的电脑上。但仍然希望将照片组织到不同事件的文件夹中,并在我们的两台计算机之间复制该组织。
By having the GIT repository master on our central server we can also view the images from our TV or access them through FTP if we need them while away from home.
通过在我们的中央服务器上拥有 GIT 存储库主服务器,我们还可以查看来自电视的图像,或者如果我们离家时需要它们,则可以通过 FTP 访问它们。
This implies a structure where the images won't change very often. Rarely they'll get moved around. The most common action will be to add folder with new images to the repository and commit it to the master branch so the images are avaliable to everyone.
这意味着图像不会经常改变的结构。他们很少会四处走动。最常见的操作是将包含新图像的文件夹添加到存储库并将其提交到 master 分支,以便每个人都可以使用这些图像。
Now the question: How will the images be handled in Git? Will the Git repository be bloated up by maintaining an image for each version of the repository? Or will it only keep history of an image when it actually changes its content?
现在的问题是:如何在 Git 中处理图像?为每个版本的存储库维护一个镜像会导致 Git 存储库膨胀吗?或者它只会在实际更改其内容时保留图像的历史记录?
The difference in diskspace usages should be quite large for the two given scenarios.
对于两个给定的场景,磁盘空间使用的差异应该相当大。
回答by meagar
Every object in your repository will be stored once and referenced by it's SHA1 sum. This means that placing three copies of a 100KB image in two directories of your repo will use 100KB, plus some inconsequential amount of overhead.
存储库中的每个对象都将存储一次并由其 SHA1 总和引用。这意味着将 100KB 图像的三个副本放置在您的 repo 的两个目录中将使用 100KB,加上一些无关紧要的开销。
The same applies to pushing, pulling and branching: So long as the SHA1 sum of the image doesn't change, git will never store a second copy or have to move more than one copy across the network.
这同样适用于推、拉和分支:只要图像的 SHA1 总和没有改变,git 永远不会存储第二个副本或必须在网络上移动多个副本。
You'll be using twice the disk space on each machine though: Git maintains a copy of all it's data in a hidden .git directory in the root of your repo.
不过,您将在每台机器上使用两倍的磁盘空间:Git 在存储库根目录的隐藏 .git 目录中维护所有数据的副本。
回答by pedromcaraujo
回答by zzawaideh
It is smart enough to only track changes and not create a full replica of the image repository
它足够智能,只跟踪更改而不创建映像存储库的完整副本