Skip to content

Step 3: Set Up GitHub

We recommend creating a GitHub repository for each project you’re working on––a theme, a plugin, or a full site. You can create a free GitHub account, and then set up as many public or private repositories as you like.  GitHub will give you the flexibility of version control and can effortlessly sync with your WordPress.com production or staging site.

While there are many ways to bring your code into a GitHub repository, like using the command line, we recommend using GitHub Desktop, a free app that serves as a GUI for your pull requests. It helps developers more easily interact between local site files and your GitHub repositories in a visual way.

The tutorials below will cover this workflow.

If You’re Working on a Theme

First, you’ll need to create a local repository inside of your theme folder:

  1. In GitHub Desktop, click the Create a New Repository on your Local Drive… button, or go to File > New Repository.
  2. In the Local Path field, select the wp-content/themes/ folder in your Studio site (the path will look something like this: /Users/user_name/Studio/site_name/wp-content/themes).
  3. In the Repository Name field, type the name of the theme you’re developing. It should match the name of the plugin in your wp-content/themes/ folder.
  4. Click Create Repository.

Once you click the Create Repository button, you will have created a local repository. There will be two hidden files added to your individual theme folder (.git and .gitattributes). 

To publish your local repository to GitHub:

  1. Go to GitHub Desktop and click the Publish repository button.
  2. Name your public repository; you can give it any name. You can also select whether you want your code to be public or private using the checkbox provided. 
  3. Click Publish Repository.

Once published, you should be able to see your repository with your theme code on GitHub.

If You’re Working on a Plugin

First, you’ll need to create a local repository inside of your plugin folder:

  1. In GitHub Desktop, click the Create a New Repository on your Local Drive… button, or go to File > New Repository.
  2. In the Local Path field, select the wp-content/plugins/ folder in your Studio site (the path will look something like this: /Users/user_name/Studio/site_name/wp-content/plugins).
  3. In the Repository Name field, type the name of the plugin you’re developing. It should match the name of the plugin in your wp-content/plugins/ folder.
  4. Click Create Repository.

Once you click the Create Repository button, you will have created a local repository. There will be two hidden files added to your individual plugin folder (.git and .gitattributes). 

To publish your local repository to GitHub:

  1. Go to GitHub Desktop and click the Publish repository button.
  2. Name your public repository; you can give it any name. You can also select whether you want your code to be public or private using the checkbox provided. 
  3. Click Publish Repository.

Once published, you should be able to see your repository with your plugin code on GitHub.

If You’re Looking to Sync All wp-content Files

If you’re not working on a specific plugin or theme and want to version your files, we recommend tracking only what’s inside the wp-content folder, as this is where all your customizations are stored that make your site unique. Most of the other WordPress core files, except for wp-config.php, typically remain unmodified and can be re-downloaded if needed. The wp-config.php file is an exception, as it contains essential configuration details, primarily for your database connection.

First, you’ll need to create a local repository in your site wp-content folder:

  1. In Studio, select your site and click on open in your file explorer.
  2. Create a file named .gitignore inside the wp-content folder.
  3. Add the following folder and file names to this new .gitignore file to avoid tracking them in your repository. This will exclude the plugins required by Studio, your SQLite database, and your uploads folder. For this reason your posts, pages and images from your local site won’t be committed to your production server.
mu-plugins
database
db.php
uploads
  1. In GitHub Desktop, click the Create a New Repository on your Local Drive… button, or go to File > New Repository.
  2. In the Local Path field, select the folder of your Studio site (the path will look something like this: /Users/user_name/Studio/site_name).
  3. In the Repository Name field, type wp-content, to match the name of your wp-content folder.
  4. Click Create Repository.

Once you click the Create Repository button, you will have created a local repository. There will be two hidden files added to your wp-content folder (.git and .gitattributes). 

To publish your local repository to GitHub:

  1. Go to GitHub Desktop and click the Publish repository button.
  2. Name your public repository; you can give it any name. You can also select whether you want your code to be public or private using the checkbox provided. 
  3. Click Publish Repository.

Last updated: November 05, 2024