git status command doesn't show new untracked directories and I can't git add them.. How can I resolve this? New and untracked files are shown, the problem is only with new directories.
Asked
Active
Viewed 7,901 times
9
-
4Git tracks files not directories, alas. Are they empty directories? There are [some workarounds for that](http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository?rq=1) e.g. putting a .gitignore in the directory and committing that. – Rup Aug 29 '13 at 12:43
-
2are there files in the directories? – virtualmarc Aug 29 '13 at 12:43
-
what are the permissions of the new folder? Check and change the permissions – theTypan Feb 07 '17 at 13:36
3 Answers
17
Git
cannot add directories to the repository. Only files can be added.
If you want to add a directory put an empty .gitignore
file into it and add it.

Sergey K.
- 24,894
- 13
- 106
- 174
6
An empty file called .gitignore
in each empty folder that you would like to commit can make good sense.
Especially if you (eventually) have certain files you would like to ignore in that specific folder but not others. .gitkeep
and .keep
end up being only helpful in the fact that they exist and will not provide any other functionality. They will end up being dead weight.
At least .gitignore
in those empty folders has the potential to be useful for more than the initial intent to track a folder.

vgoff
- 10,980
- 3
- 38
- 56