Convert an existing directory into a Git working directory and push back to remote

I had this problem today where I created a Git repository and wanted to add an existing directory full of files to it as the Git working directory but I didn’t know how. This is what I came up with:

cd <to the directory>
git init
git add .
git commit -m 'your message'
git remote add origin <ip/address of origin>
git push -u origin master <or alt branch name>

Jason Edwards