Uploading a empty folder to github
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)
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.
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 git@github.com: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
.
Explanation
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.
Finding out more
If you're interested about this decision of ignoring empty directories in git you can read this thread from the git mailing list archives.
链接地址: http://www.djcxy.com/p/7866.html上一篇: 我如何在Git中添加一个空目录?
下一篇: 上传一个空文件夹给github