Following the following steps one can add a folder to existing Github repository. These steps can be and should be followed to add a directory to any git repository, whether it is on Github or Bitbucket or any other server.I have used the name
master of the default branch I am adding my code to. You can change the default branch name to any other name of your choice.
Here are the steps:
git add .
git commit -m "first commit"
git branch -M master
git remote add origin https://github.com/url_to_git_repository/repo_name.git
git push -u origin master