配置.gitignore正确以使git在不告诉文件包含文件后忽略它们

我正在尝试弄清楚如何修改.gitignore文件以使其与此源代码树一起使用。

一级供应商代码和定制代码文件夹下文件夹中的定制代码。只需要提交自定义代码,而忽略供应商代码。因此,这就是我在.gitignore文件中所拥有的,并且在大多数情况下都有效:

hybris/bin/*
!hybris/bin/custom/

如果我理解这两行,则第一行说忽略hybris / bin中的一切,然后第二行说“自定义文件夹除外”。自定义文件夹中有一些文件需要排除,它们是:.springBeans和.project。当我处于git状态时,会看到以下信息:

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   hybris/bin/custom/cnbs/cnbsinitialdata/.springBeans

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   .gitignore
    modified:   hybris/bin/custom/cnbs/cnbscore/.springBeans
    modified:   hybris/bin/custom/cnbs/cnbsfacades/.springBeans
    modified:   hybris/bin/custom/cnbs/cnbsfulfilmentprocess/.springBeans
    modified:   hybris/bin/custom/cnbs/cnbsstorefront/.springBeans
    modified:   hybris/bin/custom/cnbs/cnbsstorefront/extensioninfo.xml
    modified:   hybris/bin/custom/cnbs/cnbstest/.springBeans
    modified:   hybris/config/.project
    modified:   hybris/config/tomcat/conf/catalina.properties
    modified:   hybris/config/tomcat/conf/server.xml

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    hybris/bin/custom/cnbs/cnbsbackoffice/.classpath.bak

我已经尽我所能尝试将.springBeans和.project文件排除在外,但从来没有。关于如何将它们排除在外的任何建议?

这是我的整个gitignore文件:

# Folders to ignore at root(hybris)
hybris-sbg
installer
build-tools
c4c-integration

# Folders to ignore,whatever the place they are
.metadata
classes
hybris/bin/**/bin
gensrc

# Folders to ignore at the root of the repository
hybris/log/
hybris/temp/
hybris/data/
licenses/
hybris/hybris/sampleconfigurations/


# filter only custom extension
hybris/bin/*
!hybris/bin/custom/

# Absolute path to ignore
hybris/config/local.properties

# Filename patterns to ignore
*.class
build.xml
Generated*.java
platformhome.properties
*testclasses.xml
extensioninfo.xsd
*hmc.jar
hmc.xsd
items.xsd
beans.xsd
ruleset.xml
*.log
base.properties
SIGNATURE.SMF
package-lock.json
.DS_Store
.classpath
.project
*.swp

#  Addon specific copy folders
**/_ui/addons
**/views/addons
**/tld/addons
**/tags/addons
**/messages/addons
*_bof.jar
**/.project
**/.springBeans
yuhailin405 回答:配置.gitignore正确以使git在不告诉文件包含文件后忽略它们

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3149058.html

大家都在问