Git is ignoring subdirectory upload
I am new to Git and I'm trying to get a subfolder uploaded into my 'master'project but currently unable to. I have gotten all the files in the root folder uploaded through Git and can push and clone the root folder. I have a folder called 'includes' in the root folder (root/includes) with 5 .php files in it I would like to upload. Currently, there is a folder called "includes" when I clone the project, but there are no files in it. The files that were placed in the "includes" folder was copied from another project. I have tried cloning the project again and pushing the files in the "includes" folder, but with no luck.The following is my command trail after I clone the project and successfully retrieve the root files:
add -A includes
cd includes
add -A
cd ../
commit -a -m "uploading includes folder"
git push origin
Assembla shows that there are no files in the folder.In fact, the folder is shown as a file. Is it possible that the includes folder is being 开发者_开发知识库seen as a submodule? If I commit inside the folder, the files are then listed with "create mode" in front of them.
When I push the folder, there are files in the includes folder. Here is an output I am getting after adding a "config.php" file in the includes folder:
add config.php
fatal: Path 'includes/config.php' is in submodule 'includes'
I didn't make the subdirectory a submodule, but it is appearing as one?
If there are no files in the directory git will not stage the directory when you run git add
. Git does not care about files and directories like SVN, it tracks content changes.
See does git ignore empty folders?
Update
Since you have updated your question, I'll update my response. What you've done is an easy mistake to make, if you run git add directory
with no end /
this can add a submodule to your repository.
See my own question last year: What's happened to my directory on Github?
Ah, your update indicates that you've got submodules in the mix. If you don't know what those are, then it was probably an accident (and is easy to fix). You will probably find that you have both a .git
directory in your main directory, and an includes/.git
directory.
The solution to your problem is to remove the includes/.git
directory:
rm -rf includes/.git
Normally, Git stores all its metadata in the single .git
subdirectory at the top of your directory tree. However, if you're using submodules, then other directories will also contain .git
directories.
精彩评论