gitignore详细介绍--有栗子

.gitignore官网
Ignore file changes with Git
.gitignore 文件用法
在这里插入图片描述

举例

栗子1 ???

The pattern “foo/*”, matches “foo/test.json” (a regular file), “foo/bar” (a directory), but it does not match “foo/bar/hello.c” (a regular file), as the asterisk in the pattern does not match “bar/hello.c” which has a slash in it.????
未验证成功!!!

栗子2:除了…,忽略所有

It is not possible to re-include a file if a parent directory of that file is excluded.
Example to exclude everything except a specific directory foo/bar (note the /* - without the slash, the wildcard would also exclude everything within foo/bar):

$ cat .gitignore
# exclude everything except directory foo/bar
/*			# 除了foo/bar下的文件或文件夹,排除所有的文件或文件夹?
!/foo		# 不排除foo文件夹
/foo/*		# 排除foo文件夹下的所有文件
!/foo/bar	# 不排除foo/bar文件夹

栗子3:除了…,忽略所有

文件夹结构

uploads
…|----avatar
…|…|----default_a.jpg
…|…|----default_b.jpg
…|…|----default_c.jpg
…|----article
…|----girl

uploads/*
!uploads/avatar/
uploads/avatar/*
!uploads/avatar/default*

忽略 uploads 文件夹下的所有文件,但是保留 avatar 目录下的 default*的文件跟踪

foo/*'foo/*'的差异

rm .gitignore
echo foo/* >> .gitignore
cat .gitignore			# 结果是,foo/bar foo/test.json
rm .gitignore
echo 'foo/*' >> .gitignore
cat .gitignore			# 结果是,foo/*
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值