Git add a directory to remote repository by origin URL

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:

  1. cd /directory/to/add
  2. git init
  3. git add .
  4. git commit -m "first commit"
  5. git branch -M master
  6. git remote add origin https://github.com/url_to_git_repository/repo_name.git
  7. git push -u origin master

     

Leave a Reply