Git:.gitignore和.gitkeep文件的使用 让空文件夹被跟踪
Git:.gitignore和.gitkeep文件的使用
Git:.gitignore和.gitkeep文件的使用 https://majing.io/posts/10000001781172
.gitkeep
.gitkeep是一个占位文件。
Git是不会把一个完全空的文件夹添加到版本控制里,为了让空文件夹被跟踪,常规做法是在空文件夹里添加.gitkeep。
注意:.gitkeep并不是Git的特性。Git没有对占位文件名有要求,你可以放一个README也行。
git - What are the differences between .gitignore and .gitkeep? - Stack Overflow https://stackoverflow.com/questions/7229885/what-are-the-differences-between-gitignore-and-gitkeep
.gitkeep
isn’t documented, because it’s not a feature of Git.
Git cannot add a completely empty directory. People who want to track empty directories in Git have created the convention of putting files called .gitkeep
in these directories. The file could be called anything; Git assigns no special significance to this name.
There is a competing convention of adding a .gitignore
file to the empty directories to get them tracked, but some people see this as confusing since the goal is to keep the empty directories, not ignore them; .gitignore
is also used to list files that should be ignored by Git when looking for untracked files.
Can I add empty directories?
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 the 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 (there is also a tool MarkEmptyDirs using the .NET framework which allows you to automate this task); you can leave it empty or fill in the names of files you do not expect to show up in the directory.
最新文章
- phylogeny analysis
- WP中的语音识别(下):语音指令
- Swift3.0语言教程查找字符集和子字符串
- 《JavaScript模式》第1章 简介
- nc命令详解
- bzoj 1834 [ZJOI2010]network 网络扩容(MCMF)
- Java高阶面试问题合集
- VC++ try catch (转)
- Android事件侦听器回调方法浅谈
- .NET 条件查询实现--类似网上商城宝贝搜索
- windows下使用python googleprotobuf
- PHP 8大安全函数
- 使用Spire.Doc组件利用模板导出Word文档
- FFmpeg源代码简单分析:日志输出系统(av_log()等)
- python+selenium滑动式验证码解决办法
- 简单理解PHP-FPM
- Angular使用总结 --- 通过指令动态添加组件
- ZZW原创_imdpd导入时产生的错误
- 将整个文件夹推上github
- Visual Studio 2008 简体中文正式版下载及序列号(无使用期限限制,正式版)