Possible Duplicate:
How do I add an empty directory to a git repository
I want to upload a empty folder to my github repo, I created the folder but...
mkdir foldername
touch foldername
git add foldername
git commit -m 'Added foldername'
git push origin master
...always gives me the following error:
# On branch master
nothing to commit (working directory clean)
Have you tried following github's instructions?
mkdir foldername
cd foldername
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin [email protected]:your_user/foldername.git
git push origin master
You shouldn't be touch
ing the foldername
, but instead a file inside that folder.
For example touch README
. Or, even better, touch .gitignore
.
Git could track directories since a "tree" (which corresponds to a directory) has content: the list of blobs (files) and trees (sub-directories). So git actually can (in theory) record empty directories. The problem lies in the index file (the staging area): it only lists files; and commits are built from the index file.
If you're interested about this decision of ignoring empty directories in git you can read this thread from the git mailing list archives.
Git cannot track empty directories by design (an empty directory has no content, while git tries to track content). You can add a placeholder file (an empty file ought to be enough) if you want to add the directory, or live with the limitation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With