git除了子目录,它是忽略目录的文件 [英] git except a sub directory and it's files of a ignored directory

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

问题描述

  Debug / a.dll $ b使用git来管理我的源代码,我在波纹管路径中有一些文件: $ b Debug / b.exe 
Debug / c.png
Debug / Pic / a.png
Debug / Pic / b.bmp
Debug / Pic / c.dll

我想忽略这些文件:

 Debug / b.exe 
Debug / c.png

但为了忽略这些文件:

  Debug / Pic / a.png 
Debug / Pic / b.bmp
Debug / Pic / a.dll


解决方案

Git使用 .gitignore 忽略或追踪被忽略路径中的文件。



在你的情况下,你需要将它添加到项目根目录下的 .gitignore 文件中。创建文件不存在

 #要忽略的文件列表
Debug / *

#要从
上面的忽略模式中排除的文件列表Debug / Pic $ b $ Debug / Pic / *



这个样本的内容是什么 .gitignore



Debug / * - 这将忽略Debug文件夹下的所有文件

!Debug / Pic / * 在这种情况下是一个特殊字符,可以告诉git从被忽略的路径中排除给定的模式。换句话说:

我们告诉git忽略 > Debug 文件夹,但要包含 Debug / Pic / 文件夹下的所有文件。


i use git to manage my sources,i have some file in bellow paths:

Debug/a.dll
Debug/b.exe
Debug/c.png
Debug/Pic/a.png
Debug/Pic/b.bmp
Debug/Pic/c.dll

I want to ignore those files:

Debug/a.dll
Debug/b.exe
Debug/c.png

But to excelude those files from ignore:

Debug/Pic/a.png
Debug/Pic/b.bmp
Debug/Pic/a.dll

解决方案

Git use the .gitignore to ignore or to track files in ignored paths.

In your case you need to do add this to your .gitignore file in your project root directory. Create the file is it does not exist

#List of files to ignore
Debug/*

#List of files to exclude from the ignored pattern above
!Debug/Pic
!Debug/Pic/*

What is in content of this sample .gitignore

Debug/* - This will ignore all the files under the Debug folder
!Debug/Pic/* - The ! is a special character in this case telling git to exclude the given pattern from the ignored paths.

In other words:
We "told" git to ignore all the files under the Debug folder but to include all the files under the Debug/Pic/ folder.

这篇关于git除了子目录,它是忽略目录的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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