简体   繁体   English

.gitignore不会从Sourcetree中被忽略的目录内容中排除文件类型

[英].gitignore does not exclude filetypes from ignored directory content in Sourcetree

In my Unreal Engine project directory there is a Build directory and I want to ignore all the files inside except for the png files and the keystore. 我的虚幻引擎项目目录中有一个Build目录,我想忽略其中的所有文件,除了png文件和密钥库。 I want to commit my project with Sourcetree to an empty repository which has only the README.md file. 我想将带有Sourcetree的项目提交到只有README.md文件的空存储库中。

Inside .gitignore file i have the following rules: 在.gitignore文件中,我有以下规则:

# Builds
Build/*

# Don't ignore icon files in Build
!Build/**/*.ico

# Don't ignore image files in Build
!Build/**/*.png

# Don't ignore keystore file in Build
!Build/**/*.keystore

Inside my project directory looks like this: 在我的项目目录中,如下所示:

|   .gitignore
|   README.md
|
+---Build
|   +---AllDesktop
|   |   \---FileOpenOrder
|   |           CookerOpenOrder.log
|   |
|   +---Android
|   |   |   MyAndroidApp.keystore
|   |   |   project.properties
|   |   |
|   |   +---FileOpenOrder
|   |   |       CookerOpenOrder.log
|   |   |
|   |   +---res
|   |   |   +---drawable
|   |   |   |       downloadimageh.png
|   |   |   |       downloadimagev.png
|   |   |   |       icon.png
|   |   |   |       splashscreen_landscape.png
|   |   |   |       splashscreen_portrait.png
|   |   |   |
|   |   |   +---drawable-hdpi
|   |   |   |       icon.png
|   |   |   |
|   |   |   +---drawable-ldpi
|   |   |   |       icon.png
|   |   |   |
|   |   |   +---drawable-mdpi
|   |   |   |       icon.png
|   |   |   |
|   |   |   +---drawable-nodpi
|   |   |   |       vr_icon.png
|   |   |   |       vr_icon_background.png
|   |   |   |
|   |   |   \---drawable-xhdpi
|   |   |           icon.png
|   |   |

The problem is that everything inside Build is ignored but I need to keep the png files and the keystore. 问题是Build内部的所有内容都将被忽略,但是我需要保留png文件和密钥库。 I was inspired by the UnrealEngine.gitignore . 我受到UnrealEngine.gitignore的启发。 What am I doing wrong ? 我究竟做错了什么 ?

I want to add that it is a fresh install of sourcetree. 我想补充一点,它是SourceTree的全新安装。 Sourcetree also installed git, I did not have git previously installed. Sourcetree还安装了git,我以前没有安装过git。 I don't have a global gitignore. 我没有全局gitignore。

This is a bug with Sourcetree first noticed in 2015 that remains unresolved to this day: 这是Sourcetree于2015年首次发现的错误,至今仍未解决:

SourceTree for Windows does not fully honor git's gitignore pattern format. Windows的SourceTree不能完全遵循git的gitignore模式格式。

You can check out for more details the issue jiira SRCTREEWIN-3883 您可以查看更多详细信息问题jiira SRCTREEWIN-3883

You can try recreating the gitignore file, or possibly using a predefined gitignore for unreal engine. 您可以尝试重新创建gitignore文件,或者可以对虚幻引擎使用预定义的gitignore。 https://www.gitignore.io/api/unrealengine https://www.gitignore.io/api/unrealengine

That has a lot more rules but could be a start. 这有更多的规则,但可能是一个开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM