How to use Dropbox as a git repository
February 17, 2011
Dropbox is a free file synchronization/backup service where you can backup, save and share files. One of the best things is, that you can use it as git remote server.
Here is an example on how to do it. To start, open a shell/terminal window and go to your project directory:
cd ~/Projects/MyNewProject
Then enter the following lines:
git init echo > README git add . git commit -m "first commit"
Go to your local Dropbox directory and create a new directory:
cd ~/Dropbox mkdir Repositories cd Repositories
After that create a git directory on Dropbox:
mkdir myNewProject.git cd myNewProject.git
Then initialize a new git repository, go back to your local project and and link it to your Dropbox repository:
git init --bare cd ~/Projects/MyNewProject git remote add origin ~/Dropbox/Repositories/myNewProject.git git push origin master
That’s it. From there, you can just clone ~/Dropbox/Repositories/myNewProject.git that you have associated with your Dropbox account. Of course, you can also share this repository with other Dropbox users.
Nice article. Very useful to me. Thank you.
I saw this idea recently, and liked it enough that I wrote a little “git dropbox” command to mirror my current repo to my dropbox. (https://github.com/agnoster/git-dropbox/)The advantage of –mirror for me is that it gets all the branches, tags and everything. For me the dropbox repo is mainly about having a complete copy of my working repo.
So what happens when two devs push to the “origin” at the same time? Will it get fixed on rebase?
@agnoster: nice@Brian: I assume that one will get an error and has to wait for the other and then pull the changes.
If two people push to the same branch at the same time, you’ll most likely end up with a conflict on that branch and you’ll end up with a “master” and a “master (x’s conflicted copy)” and someone will have to resolve them.One warning though… I had my dropbox on a VM that was messing up on me and for some reason it set a bunch of my files to 0 bytes. This propagated to all of my computers. Thankfully, I was able to hunt most of them down and use Dropbox’s restore option, but I still find 1 or 2 files I missed every now and then.
Very useful article.. I have written a similar note on using Dropbox as an SVN repository.. Have a look: http://viralpatel.net/blogs/2011/03/dropbox-svn-subversion-repository.html
@Daniel Yeah you’re right. If a lot of people working on dropbox, it’s probably a better solution to come up with a real git server.@viralpatel: Thanks. Good article!
[...] 7.- Git. Para algunos proyectos he usado Dropbox para mis repositories de Git, aquí hay un articulo sencillo que explica como hacerlo: http://www.intermediaware.com/. [...]
[...] How to use Dropbox as a git repository [...]
[...] Intermediaware » How to use Dropbox as a git repository – March 27th ( tags: git dropbox howto reference versioncontrol free github hosting ) [...]
[...] a One X which had a tie-in deal going with HTC Sense and Dropbox) so it was nice to stumble across this blog article today while looking around for a free way to host private git repositories [...]