1

My Github repository: https://github.com/dustinrohde/crystals/tree/xp/test

It's normally very simple to add files to my working tree:

git add path/to/file1 path/to/file2 ...
git commit

But for some reason, I can't get git to recognize directories "test/res-invalid-noimage" and "test/res-invalid-noworld". I know that it's a problem with git and not with github because I searched for the files in gitk and found them not, even after repeated attempts to add them. When I just added the two directories and issued a commit, git told me that no changes had been added.

Questions and answers are welcome.

EDIT: Although the directories contain no files, just empty directories, they are used by the test suite, so I need them to exist in the working tree.

  • They wouldn't happen to be empty, would they? (Not that it should matter) – Claus Jørgensen Jan 30 '12 at 22:52
  • If that's the case, see: [How do I add an empty directory to a Git repository?](http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository) – hammar Jan 30 '12 at 22:58

3 Answers3

3

Are these empty directories? Git cannot track empty directories. In fact, it doesn't track directories at all; git only tracks files.

Lily Ballard
  • 182,031
  • 33
  • 381
  • 347
  • Ah! They aren't empty, but their only contents are empty directories. They are used by the test suite, though, so I need them to exist in the working tree. Is there a way around this? – Dustin Rohde Jan 30 '12 at 22:58
  • @DustinRohde: Put a file in the directory that you want to track. A convenient file to use is `.gitignore`, with the contents `*`, because this will instruct git to ignore all other files in that directory (note, you'll have to explicitly add this `.gitignore` by name, because by default the pattern will cause git to actually ignore the `.gitignore` itself if untracked). – Lily Ballard Jan 30 '12 at 23:00
  • @DustinRohde: Note that this requires that having a random dotfile in the directory won't screw up whatever needs those dirs. – Lily Ballard Jan 30 '12 at 23:00
1

If you should happen to have copied another git project and you still have the .git folder from the other project inside the folder which you want to track. Then you wont be able to track the folder before you remove the old .git folder.

(Ye someone might do something stupid like that, I did)

Warpzit
  • 27,966
  • 19
  • 103
  • 155
  • Same thing happened to me. Delete the internal .git and you're good to go. But I believe it is best to never do it again... – A Campos Sep 23 '18 at 06:05
0

You can not add empty directories to a git repository.

If you need the directories to be added you have to place some kind of file in them.

Daniel Kurka
  • 7,973
  • 2
  • 24
  • 43