Git系列 —— github提交一个空目录

转载自github提交一个空目录

github默认不上传空目录,有的时候需要空目录来保持程序的结构。

两种场景

1、始终保持空目录,即时里面有文件,也全部忽略掉。

建立一个.gitignore文件放到空目录内。

mkdir emptydirectory

cd emptydirectory

vim .gitignore

# Ignore everything in this directory
*
# Except this file
!.gitignore

2. 目前暂时保持空目录,以后有可能存放文件。

建立一个自定义的点文件,例如 .gitkeep放到空目录内,这样改目录就不为空了。

以后需要上传文件的时候,可以把.gitkeep删除就可以了。

参考:

How can I add an empty directory to a Git repository?

猜你喜欢

转载自www.cnblogs.com/lxyit/p/9340489.html