怎么在Git仓库里面添加空文件夹?

怎么在Git仓库里面添加空文件夹?

2个回答

可以在文件夹里面创建一个空的.gitkeep文件,这样就可以push到git仓库里了

Git仓库里面是不能添加空文件夹,请看git官方说明 Git FAQ.

Currently the design of the git index (staging area) only permits files to be listed, and nobody competent enough to make the change to allow empty directories has cared enough about this situation to remedy it.

Directories are added automatically when adding files inside them. That is, directories never have to be added to the repository, and are not tracked on their own.

You can say "git add <dir>" and it will add files in there.

If you really need a directory to exist in checkouts you should create a file in it. .gitignore works well for this purpose; you can leave it empty, or fill in the names of files you expect to show up in the directory.
36nu 分享编程知识及经验

已有账号?立即登录
微信公众号
关注36nu微信公众账号
获取最新编程知识及经验