Abdul Ahmad
Abdul Ahmad

Reputation: 10021

git not adding existing folder

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?

Upvotes: 11

Views: 38790

Answers (3)

David Pedroso
David Pedroso

Reputation: 1

In sourcetree change the selection from pending to ignored. Then add the files you want.

Upvotes: 0

wisbucky
wisbucky

Reputation: 37807

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.

Upvotes: 27

mipadi
mipadi

Reputation: 410552

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.

Upvotes: 23

Related Questions