Push Existing Codebase to Github

I have an existing codebase without version control. I want to version control it and push it in the remote repository of github. How should I do that?

1. Create a repository and use the URL

https://github.com/username/projectname.git

2. Setup the local repo if not already done

git init

git add .

git commit -m ‘Commit comment’

3. Attach the remote repository as the origin (like cloning)

git remote add origin https://github.com/username/projectname

4. Pull the remote branch to sync with the local

git pull origin master

5. Push your master branch

git push origin master