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
:Dropbox$ mkdir project_name

2. Init the remote folder into your local Dropbox

:Dropbox$ cd project_name/
: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

[BARE:master]:project_name$ ls
HEAD config description hooks info objects refs

3. Now lets clone the current GIT repository to a destination on your PC or laptop

:git$ git clone ~/Dropbox/project_name project_name_local
Cloning into 'project_name_local'...
warning: You appear to have cloned an empty repository.
:git$ cd project_name_local/ [master]:project_name_local$

4. Let’s perform an initial commit and push it into the origin

[master]:project_name_local$ ls test.txt
[master]:project_name_local$ git add -A
[master]:project_name_local$ git ci -m "initial commit"
[master (root-commit) 6916e97] initial commit 1 file changed, 0 insertions(+), 0 deletions(-) create mode
    100644 test.txt
[master]:project_name_local$ 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

Thanks to @httpdss for this contribution.

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/woow/sooprise_site.git

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

git push dropbox master