git忽略异常不能处理被忽略目录下的多个子目录 [英] git ignore exception not working multiple subdirectories below ignored directory

查看:123
本文介绍了git忽略异常不能处理被忽略目录下的多个子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



对于gitignore(!fileName.txt)的异常语法不起作用的问题。实例:

  web / [Ee] xample。[Ww] eb / [Ss] itecore / * 
!web /[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32*

不包含文件夹32x32中的文件。

我必须通过命令行手动添加它们,如下所示:



pre $ g $ git add -f -r web / [Ee] xample。[Ww] eb / [Ss] itecore / [Ss] hell / [Tt ] hemes / [Ss] tandard / [Cc] ustom / 32x32

有没有办法使用在这种情况下使用异常运算符?

解决方案

重新包含是忽略目录下多个子目录的文件你尝试),不起作用,因为如果排除该文件的父目录,则不可能重新包含文件[

对于您的示例,它会如下所示:

  web / [Ee] xample。[Ww] eb / [Ss] itecore / * 

!web / [Ee] xample。[Ww] eb / [Ss] itecore / [Ss] hell /
web / [Ee] xample。[Ww] eb / [Ss] itecore / [Ss ] hell / **
!web / [Ee] xample。[Ww] eb / [Ss] itecore / [Ss] hell / [Tt] hemes /
web / [Ee] xample。[Ww ] eb / [ss] itecore / [ss] hell / [tt] hemes / **
!web / [Ee] xample。[Ww] eb / [Ss] itecore / [Ss] hell / [Tt] hemes / [Ss] tandard /
web / [Ee] xample。[Ww] eb / [Ss] itecore / [Ss] hell / [Tt] hemes / [Ss] tandard / **
! web / [Ee] xample [Ww] eb / [Ss] itecore / [Ss] hell / [Tt] hemes / [Ss] tandard / [Cc] ustom /
web / [Ee] xample。[Ww ] eb / [Ss] itecore / [Ss] hell / [Tt] hemes / [Ss] tandard / [Cc] ustom / **
!web / [Ee] xample。[Ww] eb / [Ss] itecore / [SS]地狱/ [Tt的1 H emes / [Ss] tandard / [Cc] ustom / 32x32 *

来源:my related answer 此处



或者,您可以而是使用放置在文件目录中的.gitignore文件重新包含[更多此处]。根据口味,这可能是更漂亮的解决方案。


I am having an issue where the exception syntax for gitignore (!fileName.txt) is not working when the file is multiple subdirectories below the ignored directory.

For instance:

web/[Ee]xample.[Ww]eb/[Ss]itecore/*
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32*

does not include the files in the folder 32x32.
I have to manually add them via command line like so:

git add -f -r web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32

Is there a way to use the exception operator in a situation like this?

解决方案

Re-including a file that "is multiple subdirectories below the ignored directory" (as you try), does not work because "It is not possible to re-include a file if a parent directory of that file is excluded" [source].

As an ugly-but-working workaround, re-include all parent directories along the path before re-including your desired file, while keeping the files in these parent directories out by re-excluding them.

For your example it would like as follows:

web/[Ee]xample.[Ww]eb/[Ss]itecore/*

!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/
web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/**
!web/[Ee]xample.[Ww]eb/[Ss]itecore/[Ss]hell/[Tt]hemes/[Ss]tandard/[Cc]ustom/32x32*

Source: my related answer here.

Alternatively, you could instead use .gitignore files that are placed in the directory of files to re-include [more here]. Depending on taste, this could be the prettier solution.

这篇关于git忽略异常不能处理被忽略目录下的多个子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆