How to commit a directory into a git repository?

Viewed 75238

I read the great git tutorial here, I'm unable to create directories.

My folder structure is:

Code - Python - C++ - F# - ...

From within a initialised local repository "Code" I changed into the subfolders "Python", "C++", ... did git init and now I want the same structure on my versioning server.

% git commit -m "added directories"
# On branch master
nothing to commit (working directory clean)

I guess I got something completely wrong, did I?

Thanks, wishi

3 Answers

Create an empty .gitignore file inside the empty folder that you would like to commit.

Git will only track Files and the changes in them. So folders are tracked as part of the file changes in them. In order to create an empty folder and commit it, there have to be some files inside it.

You can add any file you want, if you don't have any files to put there, I would suggest using an empty .gitignore file. This will have no effect on your repo as long as it's empty

Related