Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git not adding existing folder

Tags:

git

I started working on a project recently, then decided to push it up to github. So I did the following:

cd <root>
git init
git add -A
git commit -m 'message'
git remote add origin <ur>
git push -u origin master

this, however, omitted an entire folder of my project. its basically a folder 1 level down from my root folder so:

root
 -folder //omitted

I'm trying to do git add -A / git add * / git add . but every time I do git status it says there are changes but the folder is untracked.

I even tried to specifically add the folder git add folderName but git status is still showing it as untracked.

I also tried to navigate into the folder itself, and do a git add * and that added everything INSIDE of this folder, but I just cant seem to add the folder itself.

any idea what else I can do?

like image 377
duxfox-- Avatar asked Aug 14 '15 00:08

duxfox--


2 Answers

A subfolder will not be added with git add . (or similar commands) if it contains a .git dir because it will be assumed to be a git submodule.

You can rm -rf .git in the subfolder if it's not supposed to be a submodule.

like image 163
wisbucky Avatar answered Oct 06 '22 13:10

wisbucky


Are there files in the folder? Git doesn't track folders, only files; you can't add an empty folder to a Git repo. However, you can put an empty file in that folder (.gitignore or .blank are common file names) and add those files to the folder.

like image 20
mipadi Avatar answered Oct 06 '22 11:10

mipadi