Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

enadabuzaid's avatar

Wordpress on Forge

I installed WordPress from Forge and want to connect it with the GitHub repository to clone it to my local and run it locally how can I do that?

0 likes
1 reply
LaryAI's avatar
Level 58

To connect your WordPress site on Forge with a GitHub repository and clone it to your local environment, you can follow these steps:

  1. Create a GitHub Repository: If you haven't already, create a new repository on GitHub to store your WordPress site's code.

  2. Initialize a Git Repository on Forge: Connect to your server via SSH where your WordPress site is hosted. Navigate to the root directory of your WordPress site and initialize a Git repository if you haven't done so already.

    cd /path/to/wordpress
    git init
    git add .
    git commit -m "Initial commit"
    
  3. Link the GitHub Repository: Add the GitHub repository as a remote to your local Git repository.

    git remote add origin https://github.com/your-username/your-repository.git
    

    Replace https://github.com/your-username/your-repository.git with the actual URL of your GitHub repository.

  4. Push to GitHub: Push your WordPress files to the GitHub repository.

    git push -u origin master
    

    You might need to set up SSH keys or use a personal access token for authentication, depending on your GitHub settings.

  5. Clone the Repository Locally: On your local machine, clone the GitHub repository to the desired directory.

    git clone https://github.com/your-username/your-repository.git
    
  6. Set Up Local Environment: To run WordPress locally, you'll need a local server environment that supports PHP and MySQL. You can use tools like MAMP, XAMPP, or Local by Flywheel to set this up.

  7. Import Database: Export the database from your Forge server and import it into your local database server. You can use tools like phpMyAdmin or command-line utilities like mysqldump and mysql for this.

  8. Update WordPress Configuration: Update the wp-config.php file in your local WordPress directory to connect to your local database.

    define('DB_NAME', 'local_database_name');
    define('DB_USER', 'local_database_user');
    define('DB_PASSWORD', 'local_database_password');
    define('DB_HOST', 'localhost');
    

    Replace local_database_name, local_database_user, and local_database_password with your local database details.

  9. Update URLs: Since your local environment will have a different URL than your live site, you'll need to update the site URL and home URL in the database. You can use a plugin like WP Migrate DB or run SQL queries to replace the URLs.

  10. Run Your Local Site: After setting up your local server and updating the configuration, you should be able to access your local WordPress site by visiting the local server's URL in your web browser.

Remember to exclude sensitive files like wp-config.php and the wp-content/uploads directory from your Git repository by adding them to a .gitignore file. This will prevent sensitive information and large media files from being stored in version control.

Please or to participate in this conversation.