Turn existing folder into git repository

First of all let me write about initial conditions:

  • I have folder on my computer’s disk with code
  • I have a new empty repository on github

Our great plan consists of following points:

  1. Navigate to project folder:
    • $ cd /path/to/project
  2. Add files to the repository:
    • $ git init
    • $ git add . (don’t forget about point sign)
    • $ git commit -m “first commit”
  3. After we have to connect to our remote repository:
    • $ git remote add origin https://github.com/mygitaccount/mynewproj.git
  4. Push files on remote server and create new branch “master” on our new github repository
    • $ git push -u origin master
  5. Last thing, type the following command:
    • $ git push

Now all your files in github repository, congratulations!
If you want to check current state type
$ git status – it shows active branch, and other useful information.
$ git branch – shows all available branches