Christian HagerSoftware Engineer // Technical Director // Photographer

Sharing GIT Repositories using Dropbox

Ever wanted to use a git repository on multiple computers or operating systems? With Dropbox this is actually quite easy now. The advantages are quite obvious. You don’t need an extra server to share, it’s free up to 2GB (which should be sufficient for many purposes) and you could even share with other people. The following steps will explain how to do it.

    1. First of all we need to create a folder on the dropbox which will contain our repositories.
      mkdir ~/Dropbox/Repositories
    2. Now we switch to our existing git project.
      cd ~/<PATH TO PROJECTS>/de.nordiccoding.gitbox

Next we need to clone the repository. Make sure to clone only the bare repository and not the working directory. You can do this using the option “–bare”.

git clone --bare . ~/Dropbox/Repositories/de.nordiccoding.gitbox.git

 

  • Now we add the clone as a remote source to our local repository
    git remote add dropbox ~/Dropbox/Repositories/de.nordiccoding.gitbox.git

 
At this point we can use

git pull dropbox <BRANCH_NAME>
git push dropbox <BRANCH_NAME>

to push an pull on the remote repository or we can add remote tracking to a branch of our local repository (e.g. master).

git config branch.master.remote origin
git config branch.master.merge refs/heads/master
git remote add origin file:///~/Dropbox/Repositories/de.nordiccoding.gitbox.git

I’m using Dropbox to sync source between MacOS and Windows 7 and I think it works like a charm.

Any enhancements? Please feel free to post a comment!

Tags: , ,

Leave a Reply

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