简体   繁体   English

没有本地存储库的Git

[英]Git without local repository

Consider the case where (for example) a 20GB directory is stored on a computer with 20.1GB disk space free, and we want to put this directory under revision control. 考虑这样一种情况:例如,一个20GB目录存储在一个没有20.1GB磁盘空间的计算机上,我们希望将该目录置于版本控制之下。 A server is available to store revision history. 服务器可用于存储修订历史记录。

In subversion, we checkout an empty directory from the server, add the files, and commit it. 在subversion中,我们从服务器检出一个空目录,添加文件并提交它。 This creates .svn directories of approximately the same size as the working directory so that it can detect changes and create diffs. 这将创建与工作目录大小相同的.svn目录,以便它可以检测更改并创建差异。 The size of the .svn directories doesn't change over time as you make regular changes. 在进行常规更改时,.svn目录的大小不会随时间而变化。

However, trying this in git (git init .; git add .; git commit) requires that we store the full history locally. 但是,在git(git init .; git add .; git commit)中尝试这一点需要我们在本地存储完整的历史记录。 As regular changes are made (assume large binary files that don't compress well), the .git directory grows until it doesn't fit on disk. 由于进行了常规更改(假设大型二进制文件不能很好地压缩),.git目录会一直增长,直到它不适合磁盘。

Is there a way to operate git so that it doesn't store the full history locally; 有没有办法操作git,以便它不会在本地存储完整的历史记录; so that it only keeps data about the tip of the branch that you're working on, and queries a remote server every time that it wants information about historical revisions or other branches? 这样它只保存有关您正在处理的分支的提示的数据,并在每次需要有关历史修订或其他分支的信息时查询远程服务器?

note: I know the .git directory is better compressed and you can make lots of revisions before it gets bigger than the .svn directory - the issue is that it grows over time whereas the .svn doesn't 注意:我知道.git目录的压缩效果更好,你可以在大于.svn目录之前进行大量的修改 - 问题是它随着时间的推移而增长,而.svn却没有

Depending on what you want to do, these answers might give you a clue Browse and display files in a git repo without cloning . 根据您的想法,这些答案可能会为您提供线索浏览并在没有克隆的情况下在git仓库中显示文件 In general, there are serveral solutions 一般来说,有几个解决方案

  • Working with the remote copy if you have ssh access. 如果您具有ssh访问权限,请使用远程副本。
  • Using an access API such as the one provided by GitHub. 使用GitHub提供的访问API。
  • Using "shallow clone": git clone --depth=1 使用“浅克隆”: git clone --depth=1

GIT is a Distributed CVS. GIT是一个分布式CVS。 The very heart of such DCVS is that they store their history locally. 这种DCVS的核心是它们在本地存储它们的历史。

You can't change that. 你不能改变它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM