17

I'm working with people using only Dropbox as version control and collaboration tool. I don't intend to change their behavior. On the other hand, I'm a git-addicted, and want to use it for my personal use.

Is their anyway to have a .git directory without syncing it in Dropbox ?

Thanks

Sam
  • 285
  • 2
  • 6
  • This isn't programming related, you're asking for Dropbox tech support. – user229044 Jun 09 '11 at 16:27
  • if you want a better solution for this, please give us some help here: https://www.dropboxforum.com/hc/communities/public/questions/201289669-Ignore-folder-without-selective-sync- – Thiago Duarte Apr 07 '15 at 02:01

5 Answers5

14

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).

Peerlow
  • 149
  • 1
  • 2
12

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)
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
9

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.

Community
  • 1
  • 1
ivarne
  • 3,753
  • 1
  • 27
  • 31
3

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
sunew
  • 477
  • 5
  • 11
  • 1
    Yes! I can attest that this actually works. Dropbox will immediately ignore the given file/folder. It doesn't delete the file/folder, just ignores it, which is just what we've been waiting for all these years. If only they will go a step further and add something like `.dropboxignore` which will automatically do this, then that would be even better. – smac89 Jan 29 '21 at 18:20
1

I've had the same problem, as sunew already mentioned you can now mark files or folders to be ignored. I use the following bash script in my Dropbox folder on MacOS to find all .git folders and parent node_modules folders in the Dropbox folder and mark these to be ignored:

# for MacOS
# exclude-files-dropbox.sh
find . -type d -name "node_modules" -prune -exec xattr -w com.dropbox.ignored 1 {} \;
find . -type d -name ".git" -prune -exec xattr -w com.dropbox.ignored 1 {} \;

The following should work on Linux:

# for Linux
# exclude-files-dropbox.sh
find . -type d -name "node_modules" -prune -exec attr -s com.dropbox.ignored -V 1 {} \;
find . -type d -name ".git" -prune -exec attr -s com.dropbox.ignored -V 1 {} \;