views:

51

answers:

3

I'm working through the Rails Tutorial. Anyone know how to add a directory in GitHub?

see section 1.3.4 http://railstutorial.org/book?version=2.3#sec:version_control

I can only get my README file and not the whole directory

+1  A: 

To add a directory to your Git repository, you should create at least one file in it. Git doesn't like empty directories in repositories.

floatless
A: 

I think the git -add . is misleading. To add new directories I usually have to issue git add -A . Checkout information about the commands you use by issuing git add --help . That should usually open a web site with more info.

I say usually because on my machine it doesn't work right now (WTF @#"!)

flq
+4  A: 

You can't add an empty directory to a git repository. Git manages files.
So if you want to have a directory be effectively added to your git repository, you need to add a file to it.

What most people do is to create empty files called .gitkeep
Just create the file and commit it.

touch tmp/.gitkeep
git add tmp/
git commit -m "we always want the tmp dir"
Damien MATHIEU
People tend to use `.gitignore` instead of `.gitkeep`.
Tass
For the morbidly curious, it *is* possible to store an empty tree in a git repository — the main obstacle is that the index does not support it and there is no motivation to. Github gets confused, though: http://github.com/jleedev/empty-tree/tree/master/empty/
jleedev
@Tass : the .gitignore file has a completely different use ...
Damien MATHIEU