Sam
Sam

Reputation: 295

Using dropbox and git without conflitcts

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

Upvotes: 18

Views: 5994

Answers (5)

Bob Swinkels
Bob Swinkels

Reputation: 26

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 {} \;

Upvotes: 1

sunew
sunew

Reputation: 526

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

Upvotes: 4

Peerlow
Peerlow

Reputation: 149

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

Upvotes: 14

ivarne
ivarne

Reputation: 3783

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.

Upvotes: 9

Aaron Digulla
Aaron Digulla

Reputation: 328850

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)

Upvotes: 12

Related Questions