.git
node_modules
wp-config.php
On the server:
cd path/to/project
wp db export # Requires wp-cli on the server
# A new file will be created, like example_com-2018-07-31-f72f641.sql
On your local machine:
cd path/to/target
rsync -az --exclude-from ../rsync-excludes.txt --info progress2 user@host:path/to/project/ .
wp config create # Requires wp-cli in your local machine
# Now you will have a brand new wp_config.php file, edit it with your DB credentials
# Now, import the dump we created on the server
wp db import name_of_backup.sql
# Also, let's rename everything to work on the local domain
wp search-replace 'http://example.com' 'http://example.test' --skip-columns=guid
# Now, let's link a theme cloned from a repo
# Start on a differente folder, like ~/wordpress/themes
git clone <theme URL>
cd /path/to/site
rm -rf wp-content/<selected theme>
ln -s path/to/repo wp-conten/<selected theme>
# Now your version-controlled theme will be used by the site