I am trying to add a branch to the master branch on GitHub and push a folder onto that branch.
The folder structure of the branch looks like - SocialApp/SourceCode/D
Scenario / Solution 1:
Ensure your Folder / Sub-folder is not in the .gitignore file, by any chance.
Scenario / Solution 2:
By default, git add . works recursively.
Scenario / Solution 3:
git add --all :/ works smoothly, where git add . doesn't (work).
(@JasonHartley's comment)
Scenario / Solution 4:
The issue I personally faced was adding Subfolders or Files, which were common between multiple Folders.
For example:
Folder/Subfolder-L1/Subfolder-L2/...file12.txt
Folder/Subfolder-L1/Subfolder-L2/Subfolder-L3/...file123.txt
Folder/Subfolder-L1/...file1.txt
So Git was recommending me to add git submodule, which I tried but was a pain.
Finally what worked for me was:
1. git add one file that's at the last end / level of a Folder.
For example:
git add Folder/Subfolder-L1/Subfolder-L2/Subfolder-L3/...file123.txt
2. git add --all :/ now.
It'll very swiftly add all the Folders, Subfolders and files.
I ran into this problem that cost me a little time, then remembered that git won't store empty folders. Remember that if you have a folder tree you want stored, put a file in at least the deepest folder of that tree, something like a file called ".gitkeep", just to affect storage by git.
If you want to add a directory and all the files which are located inside it recursively, Go to the directory where the directory you want to add is located.
$ cd directory
$ git add directoryname