How to add existing projects to Github ?

Version control is an importantUnderstand git clone , svn checkout Vs git clone 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.
Assumptions :

    1. You already have a project that you want to add on Github.
    2. You have an account on Github and you have created a new repository there.
    3. 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.
How to add existing projects to Github -0
This is the location of my repository on Github.
https://github.com/jsaurav/MongoDB-Basics
We need the location of this repository on Github while moving our local project.
Let’s start.
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

How to add existing projects to Github - 2
Step 3 : Now add all of your project files to this new repository.

$ git add *

How to add existing projects to Github - 3

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

How to add existing projects to Github - 4

Step 5 : Now commit all the files to your git repository.

$ git commit –m “First Git Commit”.

How to add existing projects to Github - 5
Step 6: Add your Github repository as remote origin. In my case it is https://github.com/jsaurav/MongoDB-Basics.git

$ 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

How to add existing projects to Github - 7
Step 8: Now finally push all of your files to the remote repository. How to add existing projects to Github - 8

$ git push origin master

Once you pushed all the changes to the repository you can go back your Github account and you will see all of your files are available their.
How to add existing projects to Github - 9

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?

Let'sConnect

Saurabh Jain

A Developer working on Enterprise applications ,Distributed Systems, Hadoop and BigData.This blog is about my experience working mostly on Java technologies ,NoSQL ,git , maven and Hadoop ecosystem.
Let'sConnect

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Add Comment Register



Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>