简体   繁体   English

使git提交所有特定类型的文件,除了几个

[英]make git commit all files of specific type except for a couple

How can I make git commit all files of one type, say *.el except for certain .el files that are specifically named. 我如何使git提交一种类型的所有文件,例如*.el但某些特定命名的.el文件除外。 So, I have the following, but the *.el seems to be overriding the .el files that I name specifically, 因此,我有以下内容,但是*.el似乎覆盖了我专门命名的.el文件,

*
ignoreme.el
ignoremetoo.el

!.gitignore
!*.el

I have tried putting the files to ignore after the *.el as well, but no dice. 我也尝试过在*.el之后忽略文件,但没有骰子。

EDIT There are also many other files/directories that need to be ignored and that is the reason for * 编辑还有许多其他文件/目录需要被忽略,这就是*的原因

If that's your .gitignore-file, try adding only the exact things you want to ignore, like so: 如果这是您的.gitignore文件,请尝试仅添加要忽略的确切内容,例如:

ignoreme.el
ignoremetoo.el

As far as I know, there is no reason to include a complete wildcard at the top ( * ) - if Git even recognizes that; 据我所知,没有必要在顶部( * )处包含完整的通配符-如果Git甚至意识到这一点; why would you ignore everything by default? 为什么您默认会忽略所有内容?

Something like git commit **.el -m "My commit message" should work with my fixed .gitignore file. git commit **.el -m "My commit message"这样的东西,我的固定.gitignore文件应该可以使用。

Update to comment: The concept still applies. 更新以评论:该概念仍然适用。 Add all the exact things you want to ignore, for instance like this: 添加您要忽略的所有确切内容,例如:

*.abc
*.def
ignoreme.el
ignoremetoo.el
bin

When committig/adding now ( git add . ), all .el files will be added except those who are ignored. 当现在committig / adding( git add . )时,将添加所有.el文件,除了那些被忽略的文件。

So you can mix and match with wildcards and specific files. 因此,您可以与通配符和特定文件混合使用。 What you should not do, is ignore everything and then try to unignore certain things - that will probably just make everything very complex to manage. 您不应该做的就是忽略所有内容,然后尝试忽略某些内容-这可能会使所有内容变得非常复杂。 You could for instance check out these gitignore-files to see what it's all about. 例如,您可以签出这些gitignore文件,以查看其全部内容。

Won't git commit anything you don't have in .gitignore? git不会提交.gitignore中没有的任何内容吗? So your .gitignore should be: 因此,您的.gitignore应该是:

ignoreme.el
ifnoremetoo.el

What it looks like you're doing is trying to not ignore all .el files (which as far as I know git does by default), then trying to ignore a couple specific files, when all you have to do is ignore specific files. 看起来您正在做的是尝试不忽略所有.el文件(据我所知git默认情况下这样做),然后尝试忽略几个特定文件,而您要做的就是忽略特定文件。

Know what I mean? 明白我的意思了吗?

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

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