git - 提交空目录

git - 提交空目录

需要在目录下创建 .gitkeep 文件,然后在项目的 .gitignore 中设置不忽略 .gitkeep。
.gitkeep 是一个约定俗成的文件名并不会带有特殊规则。

strong@foreverstrong:~/gogsgit_work/parking_system$ mkdir tmp
strong@foreverstrong:~/gogsgit_work/parking_system$ 
strong@foreverstrong:~/gogsgit_work/parking_system$ cd tmp/
strong@foreverstrong:~/gogsgit_work/parking_system/tmp$ ls
strong@foreverstrong:~/gogsgit_work/parking_system/tmp$ 
strong@foreverstrong:~/gogsgit_work/parking_system/tmp$ touch .gitkeep
strong@foreverstrong:~/gogsgit_work/parking_system/tmp$ 
strong@foreverstrong:~/gogsgit_work/parking_system/tmp$ ll
total 8
drwxrwxr-x 2 strong strong 4096 Jun 27 17:08 ./
drwxrwxr-x 8 strong strong 4096 Jun 27 17:07 ../
-rw-rw-r-- 1 strong strong    0 Jun 27 17:08 .gitkeep
strong@foreverstrong:~/gogsgit_work/parking_system/tmp$ cd ..
strong@foreverstrong:~/gogsgit_work/parking_system$ 
strong@foreverstrong:~/gogsgit_work/parking_system$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

	tmp/

nothing added to commit but untracked files present (use "git add" to track)
strong@foreverstrong:~/gogsgit_work/parking_system$ 
strong@foreverstrong:~/gogsgit_work/parking_system$ git add .
strong@foreverstrong:~/gogsgit_work/parking_system$ 
strong@foreverstrong:~/gogsgit_work/parking_system$ git commit -m "add tmp"
strong@foreverstrong:~/gogsgit_work/parking_system$ git push







猜你喜欢

转载自blog.csdn.net/chengyq116/article/details/80834155
今日推荐