Export the mysql database for your WordPress to an .sql file. Unzip it (if applicable) to a convenient place on your computer.
NOTE: If you're using phpMyAdmin to do this export (recommended), make sure that you do a "custom" export, scroll down to "Object creation options," and check these two boxes:
[x] Add CREATE DATABASE / USE statement
[x] Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement
Open your .sql file in your preferred text editor. Make the following four changes.
A) Find the line that starts "CREATE DATABASE IF NOT EXISTS" and change the database name given in that line to match the name of your repo. To keep things simple, I always make my Local and Live Databases named the same as each other, but that may not be desirable to you.
B) Find the line that starts "USE" (probably the very next line) and make the identical change as above.
C) Search for the first occurrence of 'siteurl' (which is part of an insert statement for the table `wp_options`). Here's where you'll find the first occurrence of the URL you'll want to run a "find & replace" on. If you're using Sublime text:
1) Hit Shift + Command + F and paste in that URL
2) Set the "where field to be "<current file>"
3) Put the correct URL of the staging or live site into the "replace" field.
4) Save and rename this new database as your staging/live version.
D) Import this database into your staging/live using PHPmyadmin