克隆远程存储库并随后对其进行离线访问

Cloning a remote repository and subsequent offline access to it

考虑在本地计算机上发出以下命令:

git clone git://git.test.git # <- creates folder test in current folder
cd test # amongst other files/folders, this contains the .git subfolder
git branch -r # <- to show the remote branches

假设这个输出是:

origin/C
origin/B -> origin/master
origin/A

(1) test\.git 文件夹的大小是在线远程存储库的实际和完整大小,包括所有分支和每个分支中的所有提交?我知道 .git 文件夹中的对象可能被压缩,解压缩它们可能会增加 test 文件夹的大小。这没关系,因为我想知道远程存储库的完整压缩但 完整 大小。我想知道远程存储库的完整未压缩大小。

(2) 现在关闭本地机器上的互联网连接是否安全并发出:

git checkout C

签出分支 C 还是克隆后的每次签出都需要通过互联网再次访问远程存储库?


预计到达时间:跟进 torek's 评论:

When you run git checkout C, your Git is about to give you an error ("I could not find a branch named C")

我没有收到这个错误。我获得了:

Branch 'C' set up to track remote branch 'C' from 'origin'.
Switched to a new branch 'C'

的确,正如 torek 暗示的那样,运行 git checkout C --no-guess 给出了错误:

error: pathspec 'C' did not match any file(s) known to git

(1) Is the size of test.git folder, the actual and complete size of the online remote repository including all branches and all commits in each of these branches?

大小可能有所不同,但是,git clone 为您提供了存储库的完整副本,它的大小与远程的大小大致相同。

(2) Is it safe to turn off the internet connection now on the local machine and issue git checkout C to checkout branch C or does each checkout after a clone need to access the remote repository again over the internet?

Git 在离线模式下总是。除了少数命令(fetchpushpull 是最常见的)之外,Git 总是 从您的本地 .git 目录。您必须明确告诉 Git 访问远程存储库。

请注意,遥控器不必通过互联网。例如,您可以克隆一个目录并进行实验。 git clone /path/to/some/other/repository.