Add existing project to Github

So, you have been working on a project locally and then decide you really should version control it and share it with the world. One option would be to create the repository on Github, clone it locally and then copy all the files across. But it does not have to be so messy. Here is how you add an existing project to Github without cloning it first.

Create git repo locally

We need to add a repository for your project. Git is a distributed version control system, so each machine has its own repository. This is different to centralised version control systems like Subversion, which have a single, central, repository.

Go to your project

$ cd my_project

Initialise the repository

$ git init

You should see the following message:

Initialized empty Git repository in /path/to/my_project/.git/

Add all your files to the repo:

$ git add *

Check to see that there are changes to be committed:

$ git status

You should see something like this:

# On branch master
# Initial commit
# Changes to be committed:
#   (use "git rm --cached <file>..." to unstage)
#   new file:
#   new file:   my_project.module

In this case, and my_project.module are the files I have in my project.

Commit the files.

$ git commit -m "First commit"

You should see something like this:

[master (root-commit) 8201309] First commit
 2 files changed, 74 insertions(+), 0 deletions(-)
 create mode 100644
 create mode 100644 my_project.module

Create Github project

Head over to Github and create a new project.
Create new Github repo

Add Github as remote origin

Now we need to push our changes to Github.

Go to the Github page for the repo. You will should see the URL for the Github repo, which you need to copy.

Get URL of Github repo

Add this as the remote origin:

 $ git remote add origin

Pull from Github to local:

$ git pull origin master

And finally, push the code to Github:

$ git push origin master

You should see something like this:

Counting objects: 7, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 1.71 KiB, done.
Total 6 (delta 0), reused 0 (delta 0)
 ba2316b..3dae654  master -> master

That is all there is to it! Now your project is under version control and public on Github.


Thanks for the article.
Simple and easy to understand..

This page is great! The text is concise and clear.


Excellent Tutorial simple and Forward !!!!

Cheers man! git has been wrecking my head, this sorted me out. Nice one!


this was exactly what I was looking for. good examples and actually did what it was suppose to.

Thanks, really good tutorial.

Thank you very much!
Your post was very helpful for me !

Someone should give you a prize. Good and simple tutorial, it helped a lot. Thanks.

Adrian Puente Z.

Very easy to follow approach. Thanks


FYI, When I made 'git pull origin master' i got this message. (Maybe because there was nothing in my freshly created (and empty) repo on github.

  1. d:\tmp\test_project>git pull origin master
  2. fatal: Couldn't find remote ref master
  3. Unexpected end of command stream

But I skippped that 'pull' command and just proceeded to
git push -u origin master the website, once creating fresh repo is giving this code as an example. There they use 'push -u' don't know what it does, but it worked for me.

  1. touch
  2. git init
  3. git add
  4. git commit -m "first commit"
  5. git remote add origin
  6. git push -u origin master

Thank you for these simple steps! useful for me.

Great! Thank you!

Thnx a lot ....

Thanks a lot for making it so simple

Thnx a lot ....

Nice one...! Thank you very much!

Thanks for efforts. Its short and simple.

super helpful- thank you!

Good job

I got the error message:
fatal: remote origin already exists.
And had to use:
git remote set-url origin https://etc.

First class man, so many people try to put up these things and pretend like they know what they are talking about, that was straight to the point no bullshit. Keep up the good work. :)

Thanks. Super and simple steps.
Struggled for to find these steps for hours :)

Thank You. :)

thanks, a really helpful article

Thank you!
You may use git add . instead of git add * if your initial folder contains subfolders.

thanks for the clear intructions.
we can also create remote git repository from command line using 'curl' command as follows

curl -u 'your_github_username:your_github_password' -d '{"name":"your-project-name","description":"A Git Demo Project"}'

--srihari konakanchi

Very nice article. I use it every time I need to upload a new project on bitbucket. Thank you so much!

Great. Saved me from going nuts :)

thanks for the article,it helped me.

Great tutorial. Pls expand to include how to push a FOLDER and its contents to gitHub. Thanks.

Amazing. simple and useful.

Thank you soo much for these simple & easy steps . I uplaoded a new project in github using this tutorial.

Thanks for this. Keep this updated if any changes. Lot of us use this as reference.

Amazing. simple and useful.

very good easy to understand article. thanks

Thank you very much. Your instruction is exactly of the kind I want it to be.

short and accurate, thank you!

ITs awesoome, thanks

This was very helpful. thank you:-)


Thanks a lot, very useful!!

Thank you very much, this article was very easy to understand

Thanks a lot :-)

Thanks a lot :-). It is extremely helpful!

New comments for this tutorial have been turned off.