I'm gonna start by saying only do this in new directories some where on your local machine. Don't do this in a production, staging, or even local dev. env. I will also note that you should create a branch before doing any work if you have an existing repos.
The best was to do this would be to use git and composer.
If you have git and composer set up already, fantastic! If not well... git init!
Fist step create a local git repo. (BitBucket is a good service for free private repos.)
Find a .gitignore add that to your repo and commit
$ git add .
$ git commit -a "add .gitignore"
Now add all your magento files.
$ git add .
$ git commit -a "add magento"
$ git push
If you use the .gitignore github suggests you should have added pretty much only your theme files to the repo. From here you can use
$ git clone in a new empty dir to have a semi extracted version of your theme.
If you want to take it a step further you can require magento as a dependency with composer using the Magento Composer Installer. Then in your composer.json
extra block set force override to true. Once you get composer to run you should be able to run
git status and see a bunch of deleted files. Add those changes to your repo and push. After a successful push you can delete every thing in you dir and reclone the repo. You should now be left with only your theme files.
In theory this should work don't make any permanent changes. And Feel free to ask me questions.