Wednesday, 2 April 2014

Add Existing Project to Github

I often start work on a project on my own but end up having to work with another developer as the project grows. I find Git to be the best way to share and control code and use Github or Bitbucket for central repositories. This post explains how to add Git control to a local project and create a central repository for easy sharing.

We need to create a local repository with the existing code on our local machine, an empty repository on and then connect the two.

Create local repository with existing code

In the command line, navigate to your existing project's top directory, run 'git init' and make your first commit. This adds git version control to your local project.

Create Github remote repository

Next, sign in to github and create a new repository making sure you don't tick the box for README etc. Having created your empty repository github shows you how to push the repository you created locally, so copy the URL e.g. and switch back to your local command line window.

Connect local to remote

Finally we connect the local to the remote and make the first push of code.