You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为PrestaShop 1.7创建.gitignore文件以适配开发与生产环境

Setting up a Proper .gitignore for PrestaShop 1.7 (Dev & Prod)

Hey there! Keeping your PrestaShop 1.7 repo clean and focused on what matters—your custom code, themes, and modules—is key to smooth version control across dev and production environments. Below is a tailored setup, plus pro tips to make it work for your workflow.

Core Rules (Applies to Both Dev & Prod)

These are non-negotiable—they exclude files that are auto-generated, contain sensitive data, or shouldn’t be shared across environments:

  • config/settings.inc.php # Stores DB credentials, API keys, and sensitive configs (never commit this!)
  • var/cache/** # Smarty, Doctrine, and system cache files
  • var/logs/** # Error logs and debug records
  • var/sessions/** # User session data (unique to each environment)
  • img/uploads/** # User-uploaded product images, banners, and media
  • download/** # Auto-generated PDFs, invoices, and downloadables
  • install/** # Installer files (only needed once setup is complete)
  • admin*/** # Custom admin panel directory (adjust if you use a fixed admin folder name)
  • modules/* # Ignore all third-party modules
  • !modules/your-custom-module-name/ # Exclude your custom modules (repeat for each one)
  • themes/* # Ignore all third-party themes
  • !themes/your-custom-theme/ # Exclude your custom theme(s)
  • vendor/** # Composer dependencies (teammates can install via composer install)

Development Environment Additions

Add these to ignore IDE-specific clutter, local debug tools, and temporary dev artifacts:

  • .idea/ # IntelliJ/PyCharm config files
  • .vscode/ # VS Code workspace settings
  • .DS_Store # Mac system files
  • Thumbs.db # Windows system files
  • .phpunit.result.cache # PHPUnit test cache
  • phpunit.xml.local # Local PHPUnit config overrides
  • .env.local # Local environment variables (if you use env files)

Production Environment Additions

For production, exclude extra files that don’t belong in your version-controlled repo:

  • *.sql # Database backup files
  • *.zip # Site backup archives
  • tmp/** # Temporary files generated by plugins or scripts
  • maintenance.html # Custom maintenance mode page (if you don’t want to track it)

Full Example .gitignore

Here’s how to combine all these rules into one file:

# Core PrestaShop 1.7 Ignore Rules
config/settings.inc.php
var/cache/**
var/logs/**
var/sessions/**
img/uploads/**
download/**
install/**
admin*/**
modules/*
!modules/your-custom-module/
themes/*
!themes/your-custom-theme/
vendor/**

# Dev Environment Only
.idea/
.vscode/
.DS_Store
Thumbs.db
.phpunit.result.cache
phpunit.xml.local
.env.local

# Production Environment Only
*.sql
*.zip
tmp/**
maintenance.html

Pro Tips

  1. Fix Already Tracked Files: If you’ve accidentally committed files like settings.inc.php, remove them from Git (without deleting locally) with:
    git rm --cached config/settings.inc.php
    
    Commit this change along with your new .gitignore.
  2. Personalize Without Breaking the Repo: For team members with unique local setups, use .gitignore.local (add this to your main .gitignore) or git/info/exclude to keep personal ignores out of the shared repo.
  3. Update as You Build: Whenever you add a new custom module or theme, remember to add an exclusion line (like !modules/new-custom-module/) to avoid it being ignored.

内容的提问来源于stack exchange,提问作者josedaian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:36:00