将一个空文件夹上传到github [英] Uploading a empty folder to github
问题描述
可能重复:
如何将空目录添加到git仓库
我想将一个空文件夹上传到我的github仓库中,我创建了该文件夹,但是...
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)
推荐答案
您是否尝试过按照github上的说明?
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
您不应该触摸
文件夹名称,而是该文件夹内的文件.
例如 touch README
.或者,甚至更好,触摸.gitignore
.
Git 可以跟踪目录,因为树"(对应于目录)具有内容:Blob(文件)和树(子目录)的列表.因此git实际上可以(理论上)记录空目录.问题位于索引文件中(暂存区域):它仅列出文件;并从索引文件构建提交.
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.
如果您对忽略git中的空目录这一决定感兴趣,可以阅读该线程来自git邮件列表档案.
If you're interested about this decision of ignoring empty directories in git you can read this thread from the git mailing list archives.
这篇关于将一个空文件夹上传到github的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!