git忽略异常

本文翻译自:git ignore exception

I have a gitignore file that makes git ignore *.dll files, and that is actually the behavior I want. 我有一个gitignore文件,使git忽略*.dll文件,而这实际上是我想要的行为。 However, if I want an exception ( ie to be able to commit foo.dll ), how can I achieve this? 但是,如果我想要一个异常(例如,能够提交foo.dll ),如何实现呢?


#1楼

参考:https://stackoom.com/question/DRIy/git忽略异常


#2楼

To exclude everything in a directory, but some sub-directories, do the following: 要排除目录中的所有内容,但要排除某些子目录,请执行以下操作:

wp-content/*
!wp-content/plugins/
!wp-content/themes/

Source: https://gist.github.com/444295 资料来源: https : //gist.github.com/444295


#3楼

Git ignores folders if you write: 如果您这样写,Git会忽略文件夹:

/js

but it can't add exceptions if you do: !/js/jquery or !/js/jquery/ or !/js/jquery/* 但如果执行以下操作,则无法添加例外: !/js/jquery!/js/jquery/!/js/jquery/*

You must write: 您必须写:

/js/* 

and only then you can except subfolders like this 只有这样,您才能删除像这样的子文件夹

!/js/jquery

#4楼

Just add ! 只需添加! before an exclusion rule. 在排除规则之前。

According to the gitignore man page : 根据gitignore手册页

Patterns have the following format: 模式具有以下格式:

... ...

  • An optional prefix ! 可选的前缀! which negates the pattern; 否定了模式; any matching file excluded by a previous pattern will become included again. 先前模式排除的所有匹配文件将再次包含在内。 If a negated pattern matches, this will override lower precedence patterns sources. 如果否定的模式匹配,它将覆盖优先级较低的模式源。

#5楼

Use: 采用:

*.dll    #Exclude all dlls
!foo.dll #Except for foo.dll

From gitignore : gitignore

An optional prefix ! 可选的前缀! which negates the pattern; 否定了模式; any matching file excluded by a previous pattern will become included again. 先前模式排除的所有匹配文件将再次包含在内。 If a negated pattern matches, this will override lower precedence patterns sources. 如果否定的模式匹配,它将覆盖优先级较低的模式源。


#6楼

You can simply git add -f path/to/foo.dll . 您可以简单地git add -f path/to/foo.dll

.gitignore ignores only files for usual tracking and stuff like git add . .gitignore只忽略用于常规跟踪的文件和诸如git add .类的东西git add .

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值