Version control is an important aspect of any application development, it allows you to access your code base from different machines ,allows you to make lot of mistakes and then correct them before delivering a final product ,allows you to track the progress of your project and much more. If you are reading this post I am assuming that you are having a project that you want to move on Github. Github is built on the git version control system. Git is an open source distributed version control system, more about on it can be read here – GIT Distributed Version Control
Below is a step by step guide on how to add your existing projects on Github.
- You already have a project that you want to add on Github.
- You have an account on Github and you have created a new repository there.
- You have installed git in your local system. If you are using windows you can refer this tutorial – Install git on windows.
For this tutorial I am going to add my MongoDB-Basics project on Github contains example on “Java + MongoDB”. After creating an account you can see it under Repositories tab under your Github account.
This is the location of my repository on Github.
We need the location of this repository on Github while moving our local project.
Open the git bash.
Step 1: Go to the location where your project exists that you want to move. In my case my project exists at C:\saurav\workspaces\mongo\MongoDB-Basics.
Step 2: Create a new local repository so that later its origin will be set at what we have on Github. It will create an empty repository and now we will add all our files to it.
$ git init
$ git add *
Step 4 : You can also check the status of these files with git status. You will notice something like mentioned in below snapshot.
$ git status
Step 5 : Now commit all the files to your git repository.
$ git commit –m “First Git Commit”.
$ git remote add origin https://github.com/jsaurav/MongoDB-Basics.git
Step 7 : After setting it as an origin , pull the code from it. Ideally it should be empty but in my case I have created a .gitignore and .readme file. So , after I pulled these two files will be copied to my local system.
$ git pull origin master
$ git push origin master
That’s all now your project is version controlled under Github and every operation on it will be tracked and it is publicly available to all , if you have created a public repository on Github.
Image Credits :http://git-scm.com/
How to add existing projects to Github ends here?
Latest posts by Saurabh Jain (see all)
- java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.TaskInputOutputContext, but class was expected - August 8, 2014
- org.datanucleus.store.rdbms.exceptions.MappedDatastoreException: INSERT INTO “TABLE_PARAMS” – Hive with Kite Morphlines - July 17, 2014
- java.io.IOException: can not read class parquet.format.PageHeader: null – Hive - July 12, 2014