Bitbucket is an interesting service that allows to remotely store git and mercurial projects. It is reliable, easy to configure and free. Most important, you can have as many private repositories as you want.
In this post I'll explain how to commit and init a remote git repository on bitbucket starting from a local git repository. This is what I usually do in my projects: I start them locally, then commit locally via git and finally backup a remote copy via bitbucket.
These are the steps necessary to do that:
- create a remote empty git repository on your account at bitbucket.org
- if you haven't already a local git repo, initialize your project locally by typing git init
- copy your standard .gitignore file in the project root directory
- commit locally (using the commit command or with a GUI tool like gitx, gitc, or gitk)
git remote add origin https://<username>@bitbucket.org/<username>/sampleproject.git
Here I assume that your project is named sampleproject; you must substitute the <username> key with your bitbucket account name.
If everything goes fine, you're ready to do your first push on your bitbucket repo:
git push -u origin master
To fetch the remote project from another machine just type:
git clone https://<username>@bitbucket.org/<username>/sampleproject.git