'GitHub does not let me access Subfolders
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.
Solution 1:[1]
If you do have submodule, and running git submodule status to check that out, make sure to:
- not run the command from a subfolder of your local Git repository
- or use Git 2.25 (Q1 2020)
That is because, before Git 2.25 (Q1 2020), "git submodule status" that is run from a subdirectory of the superproject did not work well. That has been corrected.
See commit 1f3aea2 (25 Nov 2019) by Manish Goregaokar (Manishearth).
(Merged by Junio C Hamano -- gitster -- in commit 88cf809, 05 Dec 2019)
submodule: fix 'submodule status' when called from a subdirectorySigned-off-by: Manish Goregaokar
When calling
[git submodule](https://git-scm.com/docs/git-submodule) statuswhile in a subdirectory, we are incorrectly not detecting modified submodules and thus reporting that all of the submodules are unchanged.This is because the submodule helper is calling
diff-indexwith the submodule path assuming the path is relative to the current prefix directory, however the submodule path used is actually relative to the root.Always pass
NULLas theprefixwhen running diff-files on the submodule, to make sure the submodule's path is interpreted as relative to the superproject's repository root.
Solution 2:[2]
I have the same issue and got resolved by doing the following.
I was trying to synch my local repo to my github repo, but could not due to subfolders having been git initialized by mistake. Once the entries were removed and re-initialed the local state is reflected on my github repo.
- removed all the
.gitfolders from the sub folders as well as from root. git initgit add .git commit -m "first commit"git branch -M master(if you are committing from the branch switch to branch)git remote remove origin(if you have any)git remote add origin https://github.com/abcd1234/xxxxxxx.gitgit push -u origin master
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Community |
| Solution 2 | joanis |
