Reputation: 1513
This thread here shows commands to do this. Particularly:
git add <folder name>
git commit -m "a commit message"
git push -u origin master
However, this only creates an empty folder in the git repo, without actually uploading the content of that folder (from local). This is the output when running those 3 lines:
[master 7e085c5] my commit message
1 file changed, 1 insertion(+)
create mode 160000 my folder
How do I just simply upload a folder with content onto an existing repo (under certain sub folder)? I am working on Mac.
Upvotes: 0
Views: 145
Reputation: 488193
Git does not store folders. What you have is neither a folder nor a file: it's a gitlink, which is half of a submodule. You can tell from this:
mode 160000
The magic constant 160000
means gitlink.
What this means is that the folder you're trying to add files from is itself a Git repository. Git refuses to store a Git repository inside a commit (for good but administrative reasons) and any attempt to do that results in the storage of the gitlink half of a submodule. You, the programmer, are expected to understand this and to add the other half of the submodule yourself.
If you don't know what a submodule is, you probably don't want one. Remember that a Git repository stores commits, not files; if you want to store files, not another Git repository, you'll want to extract the files from some commit from the other Git repository, put those into your own Git repository's working tree, and then add and commit those files.
A quick and dirty way to do that is to remove, recursively, the .git
directory within the submodule. Remember that this completely destroys your repository. It leaves only the working tree files. If that's OK—if this Git repository only exists because you cloned it from somewhere else, and getting rid of the repository while keeping the checked out files is the goal—then go ahead and do that.
If you do want submodules, pay attention to the warning you got. Use git submodule add
instead of attempting to add the other repository directly.
Upvotes: 1