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.xml
but it's not appearing at all within the git status
output.
I'm not sure what to do at this point.
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:
/*
!/app
app/*
!/app/etc
app/etc/*
!/app/etc/modules
app/etc/modules/*
!/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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.