Create a Repository From an Existing Source
To set up GitHub Deployments on WordPress.com, you first need to create a GitHub repository using your local source files. This guide will walk you through the process. It assumes you already have a GitHub account and Git installed on your computer.
Create a local Git repository
If you already have a local Git repository, you can skip this step and go directly to the Adding your files to GitHub section.
For those who need to create a local Git repository, the following guides will walk you through the process using the terminal. If you prefer a visual interface, consider using GitHub Desktop instead.
Studio by WordPress.com projects
Sites created with Studio include a full WordPress installation. While you can add all of these files to GitHub, it’s recommended to create the repository for only the files you need to keep version controlled. This is typically the wp-content
folder or individual plugins and themes.
Let’s assume you have created a new theme and plugin in your Studio project. Your project file structure should look something like one of the following:
site-folder/...
site-folder/wp-content/...
site-folder/wp-content/themes/mytheme
site-folder/wp-content/plugins/myplugin
- In Studio, select your local site and click “Open in Terminal“. The current working directory will be your site folder.
- Run
cd wp-content
. - Run
git init
to create your Git repository. (If you want to create a repository for a single plugin or theme,cd
into that directory before runninggit init
). - Next, run
git add themes/mytheme plugins/myplugin
to tell Git to track your files. You can also rungit add .
to track all files in the current directory. - Finally, run
git commit -m "Initial commit"
.
You can now move on to Adding your files to GitHub.
Local by WP Engine® projects
Like Studio, sites created with Local include a full WordPress installation. While you can add all of these files to GitHub, it’s recommended to create the repository for only the files you need to keep version controlled. This is typically the wp-content
folder or individual plugins and themes.
Let’s assume you have created a new theme and plugin in your Local project. Your project file structure should look something like one of the following:
public/...
public/wp-content/...
public/wp-content/themes/mytheme
public/wp-content/plugins/myplugin
- In Local, select the site you are working on and click “Open site shell“. The current working directory will be
public
, which is the site’s root folder. - Run
cd wp-content
. - Run
git init
to create your Git repository (If you want to create a repository for a single plugin or theme,cd
into that directory before runninggit init
). - Next, run
git add themes/mytheme plugins/myplugin
to tell Git to track your files. You can also rungit add .
to track all files in the current directory. - Finally, run
git commit -m "Initial commit"
.
You can now move on to Adding your files to GitHub.
wp-env projects
wp-env
is the official WordPress development environment based on Docker. This section assumes you have already set up a wp-env
project. If not, you can follow this guide to get started.
Let’s assume you’ve created a new theme and plugin. Your project file structure should look something like one of the following:
<project root>/wp-content/themes/mytheme
<project root>/wp-content/plugins/myplugin
or
<project root>/themes/mytheme
<project root>/plugins/myplugin
- Using
cd
, navigate to the<project root>
in your terminal. - Run
git init
to create your Git repository (If you want to create a repository for a single plugin or theme,cd
into that directory before runninggit init
). - Next, run
git add .
to tell Git to start tracking your files. - Then, run
git commit -m "Initial commit"
to commit your files.
You can now move on to Adding your files to GitHub.
Files on WordPress.com sites
The previous examples focused on adding local files to your GitHub repository, but what if the files currently exist on a WordPress.com site?
To add these files to GitHub, you can use the rsync
command to retrieve them from the server. Alternatively, you can copy the files to your local system using an FTP client.
To use the rsync
command:
- Go to
wordpress.com/hosting-config/:your-site
. - Under SFTP/SSH credentials, click “Create credentials” if you have not already done so.
- Enable SSH if it’s not already.