Skip to content

Instantly share code, notes, and snippets.



Created Apr 19, 2012
What would you like to do?
Using Git with Dropbox
### Instructions source ####
-- make empty repo on dropbox:
cd ~/Dropbox/RipeApps/Git
mkdir -p newname.git
cd !$
git --bare init
-- push your junk into it
cd ~/Projects/myrepo
git remote add dropbox file://$HOME/Dropbox/RipeApps/Git/newname.git
git push dropbox master
Using Dropbox as a Git repository
So last month I wrote a bit about setting up your own personal Git repositories on a Linux box, and how to use that for sharing code.
I’ve had a slight epiphany since then: what if I just used the awesome Dropbox (my referral link, if you’re likely to sign up) to share Git repositories between computers? Dropbox seems able to get through most corporate firewalls (my previous employer blocked SSH, for example), and is very unobtrusive in its synchronisation behaviour.
Enough introductions, make with the commands
Okay, here we go. Basically, we’re just going add a new remote which points at Dropbox (in the same way the origin remote typically points at your primary external repository). Please note these instructions should be mostly *Nix agnostic—but they’re only tested on OS X.
First, create the Git repository in Dropbox (assuming your repository is named myrepo):
cd ~/Dropbox
mkdir -p repos/myrepo.git
cd !$
git --bare init
And that’s the repository created. Basically we made a bare repository in the Dropbox directory.
Now we can add the new remote to our existing repository (again, assuming it lives at ~/Projects/myrepo).
cd ~/Projects/myrepo
git remote add dropbox file://$HOME/Dropbox/repos/myrepo.git
git push dropbox master
And we’re done. We’ve created the repository, linked a Git remote to it, and pushed the master branch to the repository. This Git repository will now be available on all computers that your Dropbox account is.
Pulling from the repository
When you get to a computer that shares this Dropbox account, but hasn’t checked out Git yet, do as follows:
cd ~/Projects
git clone -o dropbox file://$HOME/Dropbox/repos/myrepo.git
Which will add your repository locally, and automatically set up a remote called dropbox which auto–merges with master.
I think this approach could be valuable for things like keeping personal documents or text files in version control (or indeed personal coding projects) without bothering to set up your own Linux box or server. Git really does make these things incredibly easy.

This comment has been minimized.

Copy link

@neuralsandwich neuralsandwich commented Oct 31, 2013

This is a bad, bad, bad idea. Dropbox is know to lose files (I doubt it is regular), this is the big no for this idea, especially for anything that is important. Losing parts of the git repository before you have push a copy to a remote locate would help destroy any repo.

Dropbox will also create conflict copies If you updated a lot on a machine and the conflict was to happen then you will have a very long and tedious process or having to fix all of the conflicts with the git files and possible your code files as well.

I have seen this idea in several places and wish people would look into how to use git (a already DVCS) with either a service like github or bitbucket. You could also just use a Linux machine, which would happily clone from any other machine using SSh, which is what git is designed to use.


This comment has been minimized.

Copy link

@alistaircom alistaircom commented Aug 24, 2016

Are comments from @neuralsandwich still relevant? Not sure Dropbox has lost anything for me in years.


This comment has been minimized.

Copy link

@rosenfeldamir rosenfeldamir commented Jun 13, 2018

At the risk of being a bit late, I have had very bad experience with managing code with dropbox instead of git. I have lost code a few times which forced me to move my precious code directories out of dropbox, excluding those which I don't really change anymore.


This comment has been minimized.

Copy link

@bgolinvaux bgolinvaux commented Oct 3, 2018

Here is a safer alternative (in terms of conflicts... because I am using Dropbox a lot, in a very dynamic fashion, editing big psd files in place,... and never lost a single file..) :

Although pulls and pushes are obviously slower (going through the network everytime).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment