1. Go to GitHub and create a new Repository
You don’t need to add README.md or .gitignore at this moment. Just make you have a private repository, and we don’t want the world to see our WordPress install.
2. Log in to your server with PuTTY and add .gitigonre
First, let’s go to the public_html/
(document root) folder and add the .gitignore
.
This is how we exclude the wp-config.php
and .htaccess
to be sent to GitHub.
Note: We will come back and copy/paste the wp-config.php
contents to our local server (replace values with local database username, password, etc.), but we don’t want to send this file to GitHub for security reasons.
$ cd ~/www/wpbp.cc/public_html $ nano .gitignore > wp-config.php > .htaccess
3. First commit
Then it is time to do our first commit.
You may have another method, but this is a standard way I usually do it.
Stay in the public_html/
folder and replace the wpbp
URLs with your own GitHub repository URL.
$ git init $ git config remote.origin.url origin git@github.com:wpbpcc/wpbp.git $ git remote set-url origin git@github.com:wpbpcc/wpbp.git $ git add . $ git commit -m "first commit" $ git branch -m main $ git push origin main
Note: Be sure to use the SSH URL that starts with git@github.com
.