Have you ever looked for a cheap and efficient way to set up a GIT repository among multiple users without going through external services.
Some of them are really useful such as bettercode.net which allows to have private GIT repositories up to 2 GB.
Well, what is tiring about such services is that they have a looot of options.
When the point is only to look for a way to create a GIT repository and to code, why using such services?
Why not using a different way and simply create what you want: a CVS or GIT repository and not something else.
At this moment comes Dropbox.
Have you ever heard about it?
It is an external storage service that permits to share files among multiple computers synchronously.
The idea of GIT inside Dropbox is to put your remote GIT repository inside a Dropbox.
This way, your “remote” GIT repository is synchronized among all the computers linked to the Dropbox account.
Setting it is pretty simple.
First create an account in the Dropbox website and install Dropbox on your machine after downloading its client. Then you need on your machine GIT, git-core is most of the time sufficient.
After installing the package Dropbox on your machine, you will be asked to set a folder where all the files are synchronized, let’s call it $BOX_FOLDER here.
It may be better to subdivide the GIT folder in your Dropbix folder with something like $BOX_FOLDER/git.
Then respect the following steps to have new GIT folder called mygit.git.
1) Create remote repository in your Dropbox
cd $BOX_FOLDER/git
mkdir mygit.git
cd mygit.git
git init --bare
OK, now your remote repository is set. This GIT folder is the data that will be sent to your Dropbox.
2) Create folder on your local machine in your local repository… let’s say $LOCAL_FOLDER
mkdir $LOCAL_GIT_FOLDER
cd $LOCAL_GIT_FOLDER
git init
git remote add mygit file:///$BOX_FOLDER/git/mygit.git
git fetch mygit
By doing that your local folder is set and linked to the remote repository in your Dropbox.
When adding a remote connection to local folder “file://” means that remote repository is on your local machine.
3) Push your first commit
# Write some files
#commit them
git commit
git push mygit master
And you are done with your 1st commit!
You can then continue your stuff.
Advantages of this method:
- Cheap and easy way to create private GIT repositories.
- In case of multiple users, simply share the password and username of the Dropbox where repo is located!
- Flexibility is wonderful, you can setup permissions to repository if you want.
Some web hosting services do not allow you shell connection. Here you can do as you wish as remote repository is synchronized with you local machine.
Disadvantages:
- [Edit] A GIT commit create several objects files that need to be synchronized with the remote server. If at the same time another user commits code before the synchronization of the first commit is done, folder may become corrupted. GIT in Dropbox may be better for a single developer or a team having a unique committer
- Even if Dropbox is a cool tool, its synchronization takes some delay if several machines are linked at the same time. This delay may be from seconds to minutes, generally not more.
- Dropbox may also cut a connection while synchronizing. If this happens, a condition to always keep the consistency of your GIT repository is to have only one machine linked to your Dropbox at the same time.