git 分支如何在 windows 上工作?两个文件但只显示一个文件

How does git branches work on windows? Two files but only shows one file

我假设 git 本质上是复制源文件或至少记录差异。但是您只能在 windows 上看到当前分支的版本,您需要签出到不同的分支才能在 windows.

上打开它的版本

所以当你有一个源文件的两个分支时,你必须有两个文件对吧?在你的硬件上?但是 windows 资源管理器只能看到其中一个,即当前分支的文件。

所以另一个文件是隐藏的?不使用git怎么看?

从技术上讲,如果我有一个文件的无限分支,它会占用所有 space 并且 windows 资源管理器将只能看到一个只有一个大小的文件吗?那你怎么知道你做分支的时候不是运行 out space?

并且说不知道如何使用 git 的人在我的计算机上,并且想查看我的源文件,其版本不在当前分支上,他将如何做那?

So when you have two branches of a source file, you must have two files right? On your hardware? but the windows explorer can only see one of them, the current branch's file.

您可能习惯于像 Subversion 这样的系统,其中每个分支都在自己的目录中,但现在 Git 就是这样工作的。

Git 跟踪许多在您的工作副本中不可见的信息,包括来自其他分支的文件版本。此信息存储在 .git/ 目录中,该目录(通常)位于存储库的根目录中。

And technically, if I have infinite branches of a file, will that take up all the space and the windows explorer will only see one file with the size of only one?

技术上你不能有无限分支:-)。

存储库中每个文件显示的文件大小将是该文件在活动分支中的大小。当你添加新的提交时,你的 .git/ 目录会变大,但不会很快。 Git 在存储数据方面非常高效。

分店很便宜。添加分支会在 .git/ 目录中创建一个 40 字节的文件。

And say someone who doesn't know how to use git is on my computer and wants to look at my source file with the version that is not on the current branch, how would he go about doing that?

您可以为他们更改分支,或使用 git show 之类的东西来检索文件并将其放在某个地方。

阅读 Pro Git, at least the section on branching and merging 可能会有帮助。