0

Following on from these questions:

I'm struggling to implement this in my own environment.

I've followed the advice and adapted it to my own needs, however, when I run git status all I get as untracked is the .gitignore itself.

I'm creating a Magento Module, which, if you've every created one, you'll know has files in odd locations throughout the Magento installation.

Here's the .gitignore I created:

# Ignore All
/*
/*/

# EXCEPT
# =============

# This
!/.gitignore

# Module Config
!/app/etc/modules/Company_Module.xml

# Module Code
!/app/code/local/Company/Module/

# Front End Design
!/app/design/frontend/base/default/layout/company_module.xml
!/app/design/frontend/base/default/template/company_module/

# Back End Design
!/app/design/adminhtml/default/default/layout/company_module.xml
!/app/design/adminhtml/default/default/template/company_module/

# JavaScript
!/js/company_module/

# Front End Skin
!/skin/frontend/base/default/css/company_module/
!/skin/frontend/base/default/images/company_module/
!/skin/frontend/base/default/js/company_module/

# Back End Skin
!/skin/adminhtml/default/default/css/company_module/
!/skin/adminhtml/default/default/images/company_module/
!/skin/adminhtml/default/default/js/company_module/

I created the following file to test its validity /app/etc/modules/Company_Module.xmlbut it's not appearing at all within the git status output.

I'm not sure what to do at this point.

Community
  • 1
  • 1
Dan Hanly
  • 7,829
  • 13
  • 73
  • 134

1 Answers1

0

Okay, I've worked out how this should be structured.

I have to treat each folder as it's own entity whilst creating the file. For example, I'll look at the root and use /* to ignore all, then go through each folder within this directory and negate what I need to negate, including negations only for the folders I want to negate. Instead of tracing the full paths for the files, I'd treat it on a folder by folder basis. See the below example:

/*
!/app
app/*
!/app/etc
app/etc/*
!app/etc/modules
app/etc/modules/*
!/app/etc/modules/Company_Module.xml

Line by line:

  1. Ignore every file in root - /*
  2. Except the app folder - !/app
  3. Within the app folder, ignore all files - app/*
  4. Except the etc folder - !/app/etc
  5. Within the etc folder, ignore all files - app/etc/*
  6. Except the modules folder - !/app/etc/modules
  7. Within the modules folder, ignore all files - app/etc/modules/*
  8. Except the module configuration file - !/app/etc/modules/Company_Module.xml

It's a little long-winded but it sure beats adding 400+ lines for ignoring each irrelevant file/folder.

I've structured the file this way, and it's expanded from 36 lines to 91 so it's not too bad. Everything has now been committed and pushed to my repo with this .gitignore structure and I can confirm it's validity.

Dan Hanly
  • 7,829
  • 13
  • 73
  • 134