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.

最新文章

  1. phylogeny analysis
  2. WP中的语音识别(下):语音指令
  3. Swift3.0语言教程查找字符集和子字符串
  4. 《JavaScript模式》第1章 简介
  5. nc命令详解
  6. bzoj 1834 [ZJOI2010]network 网络扩容(MCMF)
  7. Java高阶面试问题合集
  8. VC++ try catch (转)
  9. Android事件侦听器回调方法浅谈
  10. .NET 条件查询实现--类似网上商城宝贝搜索
  11. windows下使用python googleprotobuf
  12. PHP 8大安全函数
  13. 使用Spire.Doc组件利用模板导出Word文档
  14. FFmpeg源代码简单分析:日志输出系统(av_log()等)
  15. python+selenium滑动式验证码解决办法
  16. 简单理解PHP-FPM
  17. Angular使用总结 --- 通过指令动态添加组件
  18. ZZW原创_imdpd导入时产生的错误
  19. 将整个文件夹推上github
  20. Visual Studio 2008 简体中文正式版下载及序列号(无使用期限限制,正式版)

热门文章

  1. 谈谈hive中join下on和where
  2. matplotlib学习日记(二)----图表组成练习
  3. SonarQube - 以Docker方式启动SonarQube
  4. 痞子衡嵌入式:MCUXpresso IDE下SDK工程导入与workspace管理机制
  5. 基于数据库、redis和zookeeper实现的分布式锁
  6. 表单综合HTML
  7. leetcode网站中找到的关于trie树的JAVA版本介绍
  8. php 去除路由中index.php 通过 .htaccess 文件
  9. Redis核心原理-简单动态字符串SDS
  10. LeetCode94 二叉树的中序遍历