WordPress 的 .gitignore

适用于 WordPress 的 17 条忽略规则,可直接复制到您的仓库。

内容管理系统

WordPress 的完整 .gitignore

# 由 LFGitignore - https://lfgitignore.com 生成
# 创建:2026-10-31 21:50:01 UTC
# 技术:WordPress

### WordPress ###
# 日志档案
*.log
/wp-admin/
/wp-content/index.php
/wp-content/languages
/wp-content/plugins/index.php
/wp-content/themes/index.php
/wp-includes/
/readme.html
/wp-*.php
/xmlrpc.php
wp-config.php
/wp-content/themes/twenty*/
/wp-content/plugins/hello.php
/wp-content/uploads/
/.htaccess
/index.php
/LICENSE.txt

这些 WordPress 规则实际上忽略了什么

以下列出了每个忽略模式及其加入 .gitignore 的原因。

日志文件

模式 忽略的内容
*.log 日志档案
/.htaccess htaccess

通用

模式 忽略的内容
/wp-admin/ 核心文件说明:如果您希望暂存或提交 WP 核心文件,可以删除从本节起到 Configuration 节之前的全部规则。
/wp-content/index.php 通用
/wp-content/languages 通用
/wp-content/plugins/index.php 通用
/wp-content/themes/index.php 通用
/wp-includes/ 通用
/readme.html 通用
/wp-*.php 通用
/xmlrpc.php 通用
/index.php 通用
/LICENSE.txt 通用

配置

模式 忽略的内容
wp-config.php 配置

主题示例

模式 忽略的内容
/wp-content/themes/twenty*/ 主题示例

示例插件

模式 忽略的内容
/wp-content/plugins/hello.php 示例插件

上传

模式 忽略的内容
/wp-content/uploads/ 上传

如何将此 .gitignore 用于 WordPress

  1. 复制上面的WordPress规则,或者直接下载文件。
  2. 在 Git 仓库根目录创建名为 .gitignore 的文件,并将规则粘贴进去。
  3. 如果其中一些文件已被跟踪,请运行 git rm -r --cached . 然后再次提交 - Git 仅将忽略规则应用于未跟踪的文件。
  4. 提交 .gitignore 以便团队中的每个人都共享相同的规则。

其他 内容管理系统 .gitignore 模板

查看每个 内容管理系统 模板