Published on

How to use Dropbox as a GIT repository


Don't you ever setup another version control server, Mercurial, SVN, CVS, or any other you may know.

What is GIT?

"In software development, Git /ɡɪt/ is a distributed version control and source code management (SCM) system with an emphasis on speed. Initially designed and developed by Linus Torvalds for Linux kernel development, Git has since been adopted by many other projects."

Git on Wikipedia

What is Dropbox

"Dropbox is a file hosting service operated by Dropbox, Inc., that offers cloud storage, file synchronization, and client software. Dropbox allows users to create a special folder on each of their computers, which Dropbox then synchronizes so that it appears to be the same folder (with the same contents) regardless of which computer is used to view it. Files placed in this folder also are accessible through a website and mobile phone applications."

Dropbox on Wikipedia

How to setup a GIT repo into your Dropbox account

Of course most of you already know what is GIT or Dropbox, so let's start with the cool part of the post. Obiously you need to have Drobox and GIT installed on you PC or laptop.

  1. First you need to create an empty folder on your Dropbox.
$ cd Dropbox
$ mkdir project_name
  1. Init the remote folder into your local Dropbox
$ cd project_name/
$ git init --bare
Initialized empty Git repository in /Users/zantez/Dropbox/project_name/

Perform an ls command and you'll see some folders

$ ls
HEAD config description hooks info objects refs
  1. Now lets clone the current GIT repository to a destination on your PC or laptop
$ git clone ~/Dropbox/project_name project_name_local
Cloning into 'project_name_local'...
warning: You appear to have cloned an empty repository.
$ cd project_name_local/ $
  1. Let's perform an initial commit and push it into the origin
$ ls test.txt
$ git add -A
$ git ci -m "initial commit"
[master (root-commit) 6916e97] initial commit 1 file changed, 0 insertions(+), 0 deletions(-) create mode
    100644 test.txt
$ git push origin master Counting objects: 3, done.
Writing objects: 100% (3/3),
219 bytes, done. Total 3 (delta 0), reused 0 (delta 0)
To /Users/zantez/Dropbox/project_name * [new branch] master -> master

Now you're all set, start working on your GIT project ;)

or maybe you need to....

Clone your local GIT repo into your Dropbox account

Go to your dropbox folder and clone your local repo with the --bare option

git clone --bare ~/local_repo local_repo.git

Go to your local_repo folder and add dropbox git repo you've just cloned as a remote

git remote add dropbox ~/Dropbox/git/my_repo.git

It's done! but remember to push your local changes into dropbox remote.

git push dropbox master

Thanks to @httpdss for this contribution.