GitHub不允许我访问子文件夹 [英] GitHub does not let me access Subfolders

查看:249
本文介绍了GitHub不允许我访问子文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b GitHub在我的回购库中将我无法访问的文件夹变灰。这让我很担心,因为我的代码改变了在这些文件夹中!



长: p>我正在开发一个ZF2 Web应用程序并使用git进行源代码控制。 ZF2是模块化的,所以在某种程度上(很可能与composer.phar或可能与git克隆)我已经下载了一些ZF2模块到项目子文件夹。一个这样的ZF2模块是 vendor / coolcsn / csn-user



问题1:当我运行git status时,我得到这个:

  $ git status 
#在分支master上
#没有为commit提交更改:
#modified:vendor / coolcsn / csn-user(修改的内容,未跟踪的内容)

当我运行git commit时,它显示没有更改添加到提交。所以我发现我可以将我的目录更改为 vendor / coolcsn / csn-user code>,并做git status和git commit在那里。然后我可以回到项目的根目录,并在那里做一个git commit。然后,一切都很好....直到:

问题2:直到我执行git push到GitHub。在GitHub上,我的整个项目似乎已经到位,但是在GitHub上无法访问 vendor / coolcsn / csn-user !它变灰了。我无法点击它。这让我哭。我不知道为什么,我不知道发生了什么。我读过一些关于git子模块的内容。我不知道我是否有git子模块,或者如果他们是其他东西。我并没有自觉地建立任何子模块。无论哪种方式,我担心我的GitHub子模块更改没有被跟踪,或者如果他们被跟踪,他们是隐藏的,无法查看。



可能的解决方案# 1:我认为我可以在子模块中删除.git文件夹(如果它们是子模块),并直接向GitHub提交,而我的 csn-user 文件夹可能不存在变灰。但是在我这样做之前,我听说这不是可取的,我想检查所发生的一切,以及如何以任何方式正确使用git和GitHub和子模块,并在同时。



特别是寻找一系列步骤,说明或想法,让我的回购库可以通过git和GitHub访问和提交。

解决方案

您似乎在存储库中使用子模块。运行 git submodule status 查看正在使用的子模块。



问题1原因在于对根存储库和子模块的存储库提交更改有所不同。这听起来像是您正在提交子模块存储库,然后更新根存储库以将其子模块指向该新提交。如果您没有发布这些提交,这可能会有问题,因为没有其他人能够找到它们,然后检出根存储库并希望获取它所依赖的子模块。



Github没有正确显示这些目录的内容,因为它们引用了其他存储库中的特定提交,而不是根存储库本身的一部分。



虽然您可以检查所有这些文件进入你的根存储库,这听起来很危险。通过这样做,您可以销毁有关这些子文件夹内容来自哪里的信息。没有其他人(包括您将来)能够轻松识别内容来自哪里,或者您从这些存储库中获取哪些修订。

Short:

GitHub has grayed out folders in my repo that I cannot access. This worries me, as my code changes are in those folders!

Long:

I am developing a ZF2 web application and using git for source control. ZF2 is modular, so somewhere somehow (most likely with composer.phar or possibly with git clone) I have downloaded some ZF2 modules into project subfolders. One such ZF2 module is vendor/coolcsn/csn-user. I have made changes in that ZF2 module.

Problem 1: when I run git status, I get this:

$ git status
# On branch master
# Changes not staged for commit:
#       modified:   vendor/coolcsn/csn-user (modified content, untracked content)

When I run git commit, it says "No changes added to commit". And I've definitely made some changes.

So then I found that I can change my directory to vendor/coolcsn/csn-user, and do git status and git commit there. Then I can change back to the root directory of the project, and do a git commit there. Then, all is fine.... until:

Problem 2: Until I do a git push to GitHub. On GitHub my entire project seems to be in place, but the vendor/coolcsn/csn-user is not accessible on GitHub! It is Grayed Out. I cannot click on it. It makes me cry. I don't know why and I don't know what's up. I've read something about git submodules. I don't know if I have git submodules or if they are something else. I have not consciously set up any submodules myself. Either way, I am concerned that my GitHub submodule changes are not being tracked, or if they are being tracked, they are hidden, not accessible for viewing.

Possible Solution #1: I thought that I could REMOVE .git folder in the submodules (if they are submodules) and just do straight commits to GitHub, with my csn-user folder possibly not being grayed out. But before I do so, I've heard that it is not advisable, and I wanted to check on what all that is going on, and how if anyhow, I can properly use git and GitHub and submodules, and track my changes at the same time.

In particular, looking for a set of steps, instructions, or ideas on how keep my repo accessible and committable both using git and GitHub.

解决方案

You appear to be using submodules in your repository. Run git submodule status to see the submodules in use.

"Problem 1", your confusion around commits, is due to the difference between committing changes to the root repository vs to a submodule's repository. It sounds like you are committing to a submodule repository and then updating the root repository to point its submodule at that new commit. This may be problematic if you are not publishing those commits because no one else will be able to find them should then checkout the root repository and want to fetch the submodules it depends on.

Github correctly does not show the contents of those directories because they are references to specific commits in other repositories, not part of the root repository itself.

While you could check all of these files into your root repository that does sound dangerous. by doing so you destroy information about where the contents of those subfolders came from. No one else (including you in the future) will be able to easily identify where that content came from or which revision you grabbed from those repositories.

这篇关于GitHub不允许我访问子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆