Git ignore (.gitignore) file for Magento project

Git ignore (.gitignore) file for Magento project

Yesterday I was determined to write a detailed walk-trough on setting up the SVN for Magento development. After some minor frustrations I decided to let go of the SVN and make my self learn Git.

Recently guys/girls at beanstalkapp.com introduced Git support next their already great SVN hosting. As I was using beanstalkapp.com for some time now, I figured why not give it a try with Git.

My main idea for Magento related projects was this:

  • Do not add entire Magento to the repository. Reason for this is that we need speed, we do not wish to wait forever on push/pull actions on Git repository. Also, when you properly build theme/extension only relevant parts of your Magento projects are these few folders/subfolders, the rest of files can always be fetched from Magento archive file.
  • For the repository, add only few folders/sub-folders and files relevant to development (such as app/code/community/, app/code/local/, app/code/etc/modules/, app/design/frontend/default, skin/frontend/default/, etc…). This is where .gitignore file comes in place.
  • Before you pull the repository files on local computer, dump entire Magento files/installation (from either SVN channel or from archive file) to the local folder.
  • After you have dumped entire Magento to some local folder, pull the files from Git repository (overwriting the same existing local files).

And here is my sample of Git’s .gitignore file:

app/code/community/Phoenix/
app/code/core/
app/design/adminhtml/default/default/
app/design/frontend/base/
app/design/frontend/default/default/
app/design/frontend/default/blank/
app/design/frontend/default/iphone/
app/design/frontend/default/modern/
app/design/install/
app/etc/modules/Mage_All.xml
app/etc/modules/Mage_Api.xml
app/etc/modules/Mage_Bundle.xml
app/etc/modules/Mage_Centinel.xml
app/etc/modules/Mage_Compiler.xml
app/etc/modules/Mage_Downloadable.xml
app/etc/modules/Mage_Weee.xml
app/etc/modules/Mage_Widget.xml
app/etc/modules/Phoenix_Moneybookers.xml
app/etc/config.xml
app/etc/local.xml.additional
app/etc/local.xml.template
app/locale/en_US/
app/Mage.php
cron.php
cron.sh
downloader/
errors/
favicon.ico
includes/
index.php
index.php.sample
install.php
js/blank.html  
js/extjs/
js/lib/
js/prototype/
js/spacer.gif  
js/varien/
js/calendar/  
js/flash/
js/index.php  
js/mage/ 
js/scriptaculous/
js/tiny_mce/
lib/3Dsecure/  
lib/flex/
lib/googlecheckout/
lib/LinLibertineFont/
lib/PEAR/
lib/Varien/
lib/Zend/
LICENSE_AFL.txt
LICENSE.html
LICENSE.txt
media/downloadable/
media/import/
nbproject/
pear/
php.ini.sample
pkginfo/
shell/abstract.php  
shell/compiler.php  
shell/indexer.php  
shell/log.php
skin/adminhtml/default/default/
skin/frontend/base/
skin/frontend/default/blank/
skin/frontend/default/blue/
skin/frontend/default/default/
skin/frontend/default/french/
skin/frontend/default/german/
skin/frontend/default/iphone/
skin/frontend/default/modern/
skin/install/
var/
pear

With these few simple steps you ensure yourself of having minimal files in GIT repository (only those related to theme or extension development) while fetching the rest of the files from default Magento archive.

Note, using the above .gitignore file might result in missing directories in the repository. For example, you might not see the app/code/community/ folder in the repository. Reason for this is that Git (by its architectural design) does not create folders if they do not hold any content in them. To “force” the git to make all the necessary blank folders you need to place at least one file in them. I resolved the “issue” by placing blank .gitignore file to each subdirectory.

Here is the structure of my folders that get pulled into Git repository after .gitignore is in place:

.:
app
.gitignore
js
lib
media
shell
skin
structure.txt
var

./app:
code
design
etc

./app/code:
community
local

./app/code/community:
.gitignore

./app/code/local:
.gitignore

./app/design:
adminhtml
frontend

./app/design/adminhtml:
default

./app/design/adminhtml/default:
.gitignore

./app/design/frontend:
default

./app/design/frontend/default:
.gitignore

./app/etc:
modules

./app/etc/modules:
.gitignore

./js:
.gitignore

./lib:
.gitignore

./media:
.gitignore

./shell:
.gitignore

./skin:
adminhtml
frontend

./skin/adminhtml:
default

./skin/adminhtml/default:
.gitignore

./skin/frontend:
default

./skin/frontend/default:
.gitignore

./var:

Hope this gets helpful for some.

You made it all the way down here so you must have enjoyed this post! You may also like:

How to generate SSH keys for Git authorization Hrvoje Ivancic
, | 21

How to generate SSH keys for Git authorization

Local development with Valet+ Damir Korpar
Damir Korpar, | 0

Local development with Valet+

How we developed a new Morris 4×4 Center store – case study Maja Kardum
Maja Kardum, | 1

How we developed a new Morris 4×4 Center store – case study

7 comments

  1. I never understand a basic thing that is first time we have to upload all files so if we add git ignore file then how the other person start program properly , I know is a some basic thing but I want to clear what is the solution for it

    1. I’d think you would not want to ignore that so that, assuming you push your releases to a master branch that goes live, you could commit that file when doing site modifications.

  2. And here is my example.

    .project
    .metadata
    *.*~
    *.bak
    *.swp
    *~.nib
    local.properties
    .classpath
    .settings/
    .loadpath

    # External tool builders
    .externalToolBuilders/

    # Locally stored “Eclipse launch configurations”
    *.launch

    # PDT-specific
    .buildpath

    # Magento specifig
    resources/content/media/catalog/product/cache/*
    main/media/*
    main/var/*

  3. I find that Git is more than speedy enough to handle full Magento pushes and pulls. It is definitively a lot faster than SVN.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <blockquote cite=""> <code> <del datetime=""> <em> <s> <strike> <strong>. You may use following syntax for source code: <pre><code>$current = "Inchoo";</code></pre>.

Tell us about your project

Drop us a line. We'd love to know more about your project.