Create a new git repository from existing code on Bitbucket

I have code on my server at /var/www/virtual/joel.co.in/droidzone.in/htdocs/keys. I wish to import it to a new Git repo on bitbucket.

First create the empty repo on Bitbucket: Visit

Now, on the server, navigate to the directory containing the code you need to import.

cd /var/www/virtual/joel.co.in/droidzone.in/htdocs/keys

Now initialize an empty repo

#git init .
Initialized empty Git repository in /var/www/virtual/joel.co.in/droidzone.in/htdocs/keys/.git/

Now, add your files to it, and make the first commit.

git add .
git commit -a

Add a remote to it:

#git remote add origin ssh:[email protected]/droidzone/securessh.git

Push everything for the first time:

#git push -u origin --all
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.19 KiB, done.
Total 4 (delta 0), reused 0 (delta 0)
To ssh:[email protected]/droidzone/securessh.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.