Skip to content
devyarn-subhajitPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

WP-Git

A lightweight tool to manage WordPress projects with Git, enabling seamless database syncing and environment sharing without relying on heavy migration plugins.

Setup & Prerequisites

  1. Environment Variables: Create a .env file in the wp-git directory (you can copy .env_example). Fill it with your local database credentials:
    DB_HOST=localhost
    DB_NAME=your_db_name
    DB_USER=root
    DB_PASS=root
    DB_PORT=3306
  2. WP-CLI: Ensure wp.phar is located inside the wp-git directory. This is required for automatic domain search-and-replace during imports.

Usage

You no longer need to worry about manually adding PHP or MySQL/mysqldump to your system PATH! WP-Git now includes intelligent wrapper scripts that automatically detect paths from common local development tools (Local WP, XAMPP, Laragon, and MAMP) and execute the commands for you.

All scripts must be executed from the terminal/command line (CLI) in the root of your WordPress project.

For Windows (CMD): Use wp-git\export or wp-git\import

For Windows (PowerShell): Use .\wp-git\export or .\wp-git\import

For Mac/Linux (Bash): Use wp-git/export or wp-git/import

1. Exporting the Database (Pushing Changes)

Before you commit and push your work to GitHub, run this command to export your current database:

Windows (CMD):

wp-git\export

Mac/Linux/Git Bash:

wp-git/export

What it does: Exports a dump to db/latest.sql (which is tracked by git) and keeps local rolling backups in db/backup/ (which are ignored by git).

2. Importing the Database (Pulling Changes / New Setup)

When you pull new changes from GitHub, or if you just cloned the project, run this command to load the database:

Windows (CMD):

wp-git\import

Mac/Linux/Git Bash:

wp-git/import

What it does: Imports db/latest.sql into your local MySQL database and automatically runs a search-and-replace to ensure the URLs match your local environment.

3. Upgrading WP-Git

To update these core scripts from the main GitHub repository, you can call the main script:

Windows:

wp-git\wp-git.bat upgrade

Mac/Linux:

wp-git/wp-git.sh upgrade

How to Clone & Run on a New Machine

If a developer wants to clone this WordPress repository and get it running locally, they should follow these steps:

  1. Clone the repo: git clone <your-repo-url>

  2. Create local environment: Point your local server (LocalWP, XAMPP, Docker) to the cloned directory.

  3. Configure WP: Copy wp-config-sample.php to wp-config.php and configure it with your local database details.

  4. Configure WP-Git: Copy wp-git/.env_example to wp-git/.env and add those same local database credentials.

  5. Create Database: Ensure an empty database exists in your local MySQL instance.

  6. Enable Aliases: Open your terminal in the project root and run the setup script once:

    Windows (CMD):

    wp-git\setup.bat

    Mac/Linux:

    ./wp-git/setup.sh
  7. Import & Sync: You can now run the import script from any directory inside the project!

    git import
  8. 🎉 The database will be imported, URLs automatically updated, and the site will be fully operational on your local machine!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages