git 克隆中缺少文件

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

Files missing from a git clone

git

提问by hoff2

So here's what happened:

所以这就是发生的事情:

On machine A, I cloned a shared git repository. Then I started a new branch, added a directory with a bunch of files in it, committed, and pushed the new branch.

在机器 A 上,我克隆了一个共享的 git 存储库。然后我开始了一个新分支,添加了一个包含一堆文件的目录,提交并推送了新分支。

On machine B I then cloned the same shared repository, created a remote tracking branch for the new branch I'd pushed, and pulled.

然后在机器 BI 上克隆了相同的共享存储库,为我推送和拉取的新分支创建了一个远程跟踪分支。

Somehow, certain subdirectories of the directory I added at A didn't show up in B -- even though other subdirectories, ones that were added in the same commit, did.

不知何故,我在 A 中添加的目录的某些子目录没有出现在 B 中——即使其他子目录,即在同一提交中添加的子目录,也没有出现。

Going back to A, I tried to git add the directories that didn't show up. Nothing happens. I tried git log on those same directories -- the output is empty.

回到 A,我尝试 git add 没有出现的目录。没发生什么事。我在那些相同的目录上尝试了 git log - 输出为空。

Any ideas what happened, and how I can fix it?

任何想法发生了什么,我该如何解决?

采纳答案by mipadi

Are they empty directories? Git won't track an empty directory.

它们是空目录吗?Git 不会跟踪空目录。

You can also look to make sure they're not being ignored in a .gitignorefile. Git won't add ignored file (unless forced).

您还可以确保它们不会在.gitignore文件中被忽略。Git 不会添加被忽略的文件(除非强制)。

回答by Shane Geiger

If you end up with a new directory with a .git directory inside it but no files in the new directory, then perhaps running "git checkout master" will cause the files to appear.

如果你最终得到一个包含 .git 目录的新目录,但新目录中没有文件,那么运行“git checkout master”可能会导致文件出现。