Using dropbox and git without conflitcts

Selective Sync seems to be the solution, but beware: when you mark a folder as excluded, dropbox will delete it.

Just make a backup of your .git folder, mark it as excluded with Selective Sync, dropbox will delete it. When you copy the folder back, dropbox won't delete it again, and it will lack the dropbox sync mark (and its children too).


2020 update: Now dropbox has the options to mark folders or files to be ignored, as described here: https://help.dropbox.com/files-folders/restore-delete/ignored-files

attr -s com.dropbox.ignored -V 1 myfoldername

I can see two options:

  1. Use the tips given in https://stackoverflow.com/a/8603156/112019 to store the .git repository files in an external location (like ~/gitdropbox/myproject.git) with --git-dir and --work-tree. To simpelify usage you can also add a .git file(not directory) in your dropbox synced folder with the content "gitdir: /path/to/repo.git" so that you can use git as normal.

  2. Use the approach described by Dylan R. in https://forums.dropbox.com/topic.php?id=52360#post-387887 to ignore the .git folder. You then keep an empy .git folder in the dropbox system and ignore it locally with the selective sync feature and then initialize the repository. Beware that the existing .git folder gets deleted by dropbox when you remove it with selective sync so make sure you have a local backup if you have history you want to keep.


According to this thread in the Dropbox forum, you can't omit/exclude folders. There is Selective Sync but that also doesn't what you need.

So the best solution right now is to sync manually, for example with rsync(1):

  1. Create a new folder somewhere
  2. Sync this folder with the folder in Dropbox using rsync. I suggest to write a script for this.
  3. Add a git repo in this new folder
  4. Use a second rsync script to update the Dropbox folder (use --exclude .git here)

Tags:

Git

Dropbox