https://stackoverflow.com/questions/4250063/how-to-gitignore-all-files-folder-in-a-folder-but-not-the-folder-itself/5581995#5581995

put this .gitignore into the folder, then git add .gitignore

*
*/
!.gitignore

The * line tells git to ignore all files in the folder, but !.gitignore tells git to still include the .gitignore file. This way, your local repository and any other clones of the repository all get both the empty folder and the .gitignore it needs.

Edit: May be obvious but also add */ to the git ignore to also ignore sub folders.

How to .gitignore all files/folder in a folder, but not the folder itself?的更多相关文章

  1. CMake Error at cmake/OpenCVModule.cmake:295 (message): No extra modules found in folder:Please provide path to 'opencv_contrib/modules' folder

    其实,我们使用的opencv中要用的contrib/modules   是需要额外下载并在cmakelists.txt中指定的 git clone https://github.com/opencv/ ...

  2. Mac下Git项目使用的.gitignore文件

    https://www.gitignore.io/ 这个网站可以搜索特定项目.系统所需要的.gitignore 我现在主要是在Mac上用Visual Studio Code进行开发,所以直接搜索Mac ...

  3. git路径超长 及gitignore

    1 忽略路径超长 git config --system core.longpaths true 2 比较全的gitignore https://www.gitignore.io/api/vim,no ...

  4. 官方VisualStudio.gitignore配置

    官方地址 https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 示例 ## Ignore Visual Stud ...

  5. The specified file or folder name is too long

    You receive a "The specified file or folder name is too long" error message when you creat ...

  6. How to: Synchronize Files by Using Managed Code

    The examples in this topic focus on the following Sync Framework types: FileSyncProvider FileSyncOpt ...

  7. Umbraco 上传文件到另一个文件夹,而不是media files

    If you want to upload there media files to another place in the same instance of IIS, for example a ...

  8. 从source folder 下将其所有子文件夹的*.* 文件拷贝到 target folder (不拷贝文件夹名仅拷贝文件)

    因本人较懒,一直认为电脑能做的就让电脑来做,所以写下这个批处理的小脚本方便工作. 场景:碰到要拷贝一个文件夹(source folder)下的多个子文件夹(sub-folder)的文件到指定文件夹下( ...

  9. List or delete hidden files from command prompt(CMD)

    In Windows, files/folders have a special attribute called hidden attribute. By setting this attribut ...

随机推荐

  1. SpringBoot#JSR303

    __震惊了!,一遍一遍在业务逻辑中编写的验证条件被抽离了! 是什么: - Java Specification Requests 303 ,用于对javaBean 属性的验证. - 解决了什么问题: ...

  2. 从0到1完成微信小程序开发(2)

    一,小程序的文件结构 小程序包含一个描述程序的app和多个描述各自页面的page 一个小程序主体部分由三个文件组成,必须放在项目的根目录,如下: 一个小程序页面由四个文件组成,分别是: 下面是一个单页 ...

  3. linux之 文本编辑 的基础知识点

    第一步 打开终端 创建文件命令 touch 文件名.后缀名 打开文件命令 vi 文件名.后缀名 (此时进去txt文件之后为一般模式,你无法对文件进行增删改) 之后按 i    或 a    或o  都 ...

  4. 吴裕雄--天生自然C++语言学习笔记:C++ 信号处理

    信号是由操作系统传给进程的中断,会提早终止一个程序.在 UNIX.LINUX.Mac OS X 或 Windows 系统上,可以通过按 Ctrl+C 产生中断. 有些信号不能被程序捕获,但是下表所列信 ...

  5. vue小练习--音乐播放器

    1 首先建一个文件夹 放几首歌曲 2 看代码 1)基本版本 <!DOCTYPE html> <html lang="zh-CN"> <head> ...

  6. spring监听器+定时任务

    背景:在原SSM项目中,拟定在每晚的23:59:59执行一个批处理任务. 设计思路:用jdk自带的定时器触发任务执行,设置下次执行间隔为24小时.定时任务由spring的监听器去启动. jdk版本:1 ...

  7. VUE随手记坑

    1.el-select 默认选中的问题 <el-select v-model="temp.audit" placeholder="请选择"> < ...

  8. UVA - 1213 Sum of Different Primes (不同素数之和)(dp)

    题意:选择k个质数,使它们的和等于n,问有多少种方案. 分析:dp[i][j],选择j个质数,使它们的和等于i的方法数. #pragma comment(linker, "/STACK:10 ...

  9. 读书笔记 - js高级程序设计 - 第十五章 使用Canvas绘图

    读书笔记 - js高级程序设计 - 第十三章 事件   canvas 具备绘图能力的2D上下文 及文本API 很多浏览器对WebGL的3D上下文支持还不够好   有时候即使浏览器支持,操作系统如果缺缺 ...

  10. Python 官方推荐的一款打包工具

    译者:Jiong 链接: https://robots.thoughtbot.com/how-to-manage-your-python-projects-with-pipenv 在thoughtbo ...