git 空目录提交

git 空目录自动提交

  1. .git同目录下创建文件.gitignore,并编辑写入如下内容:
# git does not allow empty directories.
# Yet, we need to add this empty directory on git.
# To achieve that, we created this .gitignore file, so that the directory will not be empty thus enabling us to commit it.
# Since we want all generated files/folders in this directory to be ignored by git, we add a rule for this.
*
# And then add an exception for this specifc file (so that we can commit it).
!.gitignore
  1. 执行如下命令,为所有空目录下创建.gitkeep文件
find $PATH_TO_REPOSITORY -type d ! -path "*.git*" -empty -exec touch '{}'/.gitkeep \;

你可能感兴趣的:(other)