home

Git Repositories in Dropbox

I sometimes find it useful to push git repositories into a shared Dropbox folder instead of pushing them to an actual git server like Github. Note that these instructions are not specific to Dropbox. I will describe the basic process for pushing to a local folder that can be shared.

First you need to initialize a bare git repository. This is basically the contents of the .git folder from a normal repo without the actual working copy. This will be created in your Dropbox folder.

~/Dropbox/code % git init --bare myproject.git

Next you need a repo to sync. This can be preexisting, or you can create a new one like below. This will be in a folder outside of Dropbox.

~/code/project % git init
~/code/project % git add .
~/code/project % git commit -m "init"

Now you need to add a remote that points to the Dropbox directory. You can call it whatever you like, I generally just call it dropbox.

~/code/project % git remote add dropbox ~/Dropbox/code/myproject.git

Now you can push to the remote.

~/code/project % git push -u dropbox master

After the files have been synced to another machine you can clone the repo.

~/anotherservercode % git clone ~/Dropbox/code/myproject.git ./myproject

I’m sure there are many other explanations like this across the internet, but I hope you find it useful anyway. I know I do.

2017-01-02