.gitignore和.gitkeep有什么区别?
本文翻译自:What are the differences between .gitignore and .gitkeep?
What are the differences between .gitignore
and .gitkeep
? .gitignore
和.gitkeep
什么.gitkeep
? Are they the same thing with a different name, or do they both serve a different function? 它们是不同名称的同一个东西,还是它们都起着不同的作用? I don't seem to be able to find much documentation on .gitkeep
. 我似乎无法在.gitkeep
上找到太多文档。
#1楼
参考:https://stackoom.com/question/UKp3/gitignore和-gitkeep有什么区别
#2楼
.gitkeep
is just a placeholder. .gitkeep
只是一个占位符。 A dummy file, so git will not forget about the directory, since git tracks only files. 一个虚拟文件,所以git不会忘记该目录,因为git只跟踪文件。
If you want an empty dir and make sure it stays 'clean' for git, create a .gitignore
containing the following lines within: 如果你想要一个空目录并确保它对git保持“干净”,请创建一个包含以下行的.gitignore
:
# .gitignore sample
#################### ignore all files in this dir...
*# ... except for this one.
!.gitignore
If you desire to have only one type of files being visible to git, here is an example how to filter everything out, except .gitignore and all .txt
files: 如果你希望git只能看到一种类型的文件,下面是一个如何过滤所有文件的例子,除了.gitignore和所有.txt
文件:
# .gitignore to keep just .txt files
#################################### filter everything...
*# ... except the .gitignore...
!.gitignore# ... and all text files.
!*.txt
('#' indicates comments.) ('#'表示评论。)
#3楼
.gitkeep
isn't documented, because it's not a feature of Git. .gitkeep
没有记录,因为它不是Git的一个功能。
Git cannot add a completely empty directory . Git 无法添加一个完全空的目录 。 People who want to track empty directories in Git have created the convention of putting files called .gitkeep
in these directories. 想要在Git中跟踪空目录的人已经创建了将这些名为.gitkeep
文件放在这些目录中的约定。 The file could be called anything; 该文件可以被称为任何东西; Git assigns no special significance to this name. Git对此名称没有特别的意义。
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
文件添加到空目录中以跟踪它们,但有些人认为这令人困惑,因为目标是保留空目录,而不是忽略它们; .gitignore
is also used to list files that should be ignored by Git when looking for untracked files. .gitignore
还用于列出Git在查找未跟踪文件时应忽略的文件。
#4楼
.gitignore
is a text file comprising a list of files in your directory that git will ignore or not add/update in the repository. 是一个文本文件,包含目录中的文件列表,git将忽略或不在存储库中添加/更新。
.gitkeep
Since git removes or doesn't add empty directories to a repo .gitkeep is sort of a hack (I don't think it's officially named as a part of git) to keep empty directories in the repo. 由于git删除或不添加空目录到repo .gitkeep是一种黑客(我不认为它被正式命名为git的一部分)在repo中保留空目录。
just do a touch /path/to/emptydirectory/.gitkeep
to add the file and git will now be able to maintain this directory in the repository. 只需touch /path/to/emptydirectory/.gitkeep
即可添加文件,git现在可以在存储库中维护此目录。
.gitignore和.gitkeep有什么区别?相关推荐
- .gitkeep是什么? .gitignore和.gitkeep之间的区别(译)
你是不是在git工程里遇到过.gitkeep文件?如果你通过angular脚手架来生成angular2或者angular4工程,你会发现.gitkeep文件在./src/app/assets文件夹里. ...
- .gitignore与.git/info/exclude区别
共同点: 加入到 .gitignore 或者加入到 .git/info/exclude 的文件或文件夹都不会进行版本控制 不同点 .gitignore 与他人共享,每个人都会有这个文件 .git/in ...
- 如何.gitignore文件夹中的所有文件/文件夹,但不是文件夹本身? [重复]
本文翻译自:How to .gitignore all files/folder in a folder, but not the folder itself? [duplicate] Possibl ...
- git shanchu stash_git stash命令使用手册
修改记录压栈保存: git stash push -u -m "msg" // -u ~ --意思是包含未被跟踪的文件 git stash push -m "msg&qu ...
- .gitignore无效解决方案以及git rm和rm的区别
一. gitignore 先来了解一下gitignore的常用语法 斜杠"/"表示目录, 是否已斜杠开头有很大区别,如 /build 与 build/ 的区别:其中 build/ ...
- git add . 和 git add * 区别
git add . 会把本地所有untrack的文件都加入暂存区,并且会根据.gitignore做过滤; git add * 会忽略.gitignore把任何文件都加入. 一个 .gitignore ...
- [转]Git忽略提交规则 - .gitignore配置运维总结
在使用Git的过程中,我们喜欢有的文件比如日志,临时文件,编译的中间文件等不要提交到代码仓库,这时就要设置相应的忽略规则,来忽略这些文件的提交.简单来说一个场景:在你使用git add .的时候,遇到 ...
- Git停止跟踪rm -r --cached与ignore区别
rm -r --cached 如果你不慎在创建.gitignore文件之前就push了项目,那么即使你在.gitignore文件中写入新的过滤规则,这些规则也不会起作用,Git仍然会对所有文件进行版本 ...
- Git忽略规则.gitignore梳理
对于经常使用Git的朋友来说,.gitignore配置一定不会陌生.废话不说多了,接下来就来说说这个.gitignore的使用.首先要强调一点,这个文件的完整文件名就是".gitignore ...
最新文章
- “AI开发者大会”早鸟票抢购倒计时开始~
- iOS应用签名原理--数字签名?代码签名?双层代码签名?
- win7+ubuntu20.04双系统+easybcd安装以及Reached target Reboot卡住问题
- Android高仿大众点评(带服务端)
- 【论文笔记】DeepWalk:大型社会表示的在线学习
- spring boot部署实战
- 如何解决苹果Mac安装Axure首次打开报错的问题?
- python判断文件后缀_python判断文件夹内是否存在指定后缀文件的实例
- Python飞机大战游戏 附素材及源码
- ATA和ATAPI类型硬盘区别方法
- Smobiler的复杂控件的由来与创造
- 组策略设置计算机计划任务,windows 2008 server 域环境通过组策略下发计划任务
- 人工智能在药物不良反应预测中的应用
- 记录一下我的phpcms下载模板的下载列表页面不能够显示出列表页面
- 蓝桥杯——大臣的旅费
- 四款最热门的云计算产品
- python画聚类图、并且把聚类图保存起来_Python利用igraph绘制复杂网络聚类(社区检测)结果图-Go语言中文社区...
- 地址转化net配置(公司网络通外网实验)(图文讲解)
- 【原创】uniapp开发的微商个人相册多端小程序源码以及安装
- matlab与amesim,amesim与matlab联合仿真步骤(自己总结)(精)