The beauty of Git in Dropbox
I have been debating with friends about the power of git merged to the simplicity of Dropbox.
Hear me out. I can see a very cool feature when using git within a dropbox folder.
Imagine you are working on several computers (one at home, one at work, one laptop). With git, you can (obviously) pull to get the latest version of your branch on all your devices. But if you put your git repo on dropbox, you just fire your laptop on and your project will be up to date !
What do you think about this workflow ? Would you do this ? Do you see any problems with this usage ? I would love to hear more.
32 comments
[ 0.22 ms ] story [ 76.0 ms ] threadGit is for long-term version control, working out of Dropbox is like having a script running that stashes and unstashes every change you make so that its in the git-reflog.
There are occasionally conflicts, but I've never actually gotten a corrupted repository. All I ever do is go with the latest version of things using 'find' to delete the conflicts.
On the other hand, the top voted answer on this SO question demonstrates how one might use a Dropbox directory as a git remote, so that you can push code there intermittently, preventing the trouble with constant writes to the Dropbox.
http://stackoverflow.com/questions/1960799/using-git-and-dro...
Putting just `.git` in Dropbox seems like it would be fine, though.
Conceptually, it's the same as using a hosted git remote repo, like Github. The only thing it saves you is having to type the git push and pull commands...not a huge savings IMO.
Besides that, the only advantage I can see is that the Dropbox process is private by default, whereas Github repos are public unless you pay.
Not sure why would i need to add dropbox to equation?
Packrat is a Dropbox Pro add-on feature that saves your file history indefinitely.
Dropbox saves a history of all deleted and earlier versions of files for 30 days for all Dropbox accounts by default. If you have the Packrat add-on, Dropbox saves those files for as long as you have the Packrat add-on. With Packrat, you never have to worry about losing an old version of a file.
https://www.dropbox.com/help/113/en
If I hadn't been using Dropbox, before leaving work, I would have to pull, and sometimes I just don't have time.
(This is one example out of many)
For example:
It was only the index file and not anything irreplaceable (not that git does a lot of mutating of files in general). But it rapidly ended my experiment with git on Dropbox.The major benefit is that I don't have to remember to commit and push my changes before switching from one computer to another. When I'm leaving work, I'm often in a hurry; when I get home, all of my work comes with me. Same thing applies to travelling with my laptop.
The major problem is that Dropbox occasionally fails. Because I have come to rely heavily upon this setup, a failure causes significant pain. In my experience, Dropbox has failed in 2 ways.
1. I make some changes on computer A. Dropbox screws up when syncing the change to computer B. When I switch to computer B, I discover that the repository on computer B is messed up (HEAD has been updated, but not the working tree; or the local repository is messed up so that 'git status' fails; or something else bizarre). In this situation I must switch back to computer A, move the 'good' repository outside of Dropbox, wait for Dropbox sync to complete, move the repository back into Dropbox, wait for sync to complete, then finally switch back to computer B and wait for Dropbox sync to complete. You can imagine how this process would be extra painful when it requires you to commute back and forth between home and office for each step.
2. I make some changes on computer A. Dropbox has silently stopped syncing the repository on computer A. When I switch to computer B, I discover that none of the changes made on computer A have synced. In this situation, restarting Computer A usually causes the Dropbox sync to resume. Troubleshooting this situation follows a similar course to situation 1.
I have communicated with Dropbox support extensively about Situation 2, and I believe that it is related to the '10,000 folder limit' for Dropbox on Linux. See the section "Monitoring more than 10000 folders" on this page:
https://www.dropbox.com/help/145/en
Git uses a very large number of folders (usually around 1500) for each repository. This does not play well with Dropbox on Linux. When Situation 2 occurs, Dropbox gives every indication that it is working correctly; files that are not syncing show the "green checkmark", and the Dropbox tray icon shows "All files up to date". Troubleshooting Situation 2 was a thoroughly enraging experience.
A good precaution is to push your personal working branch to GitHub (or your remote repository of choice) as a backup when using this setup. Treat this remote branch as disposable; if you rebase your working branch, you can just delete the remote branch and push your rebased branch (`git push origin :my-working-branch`, `git push origin my-working-branch`).
So, there have been some serious issues, but altogether I am very happy with my setup. I like the flexibility of not having to commit and push changes when I'm switching from one computer to another, and in general I feel the daily benefits have outweighed the occasional problems.
A few have mentioned syncing issues, so if you try the Dropbox approach, think about what the worst that could happen might be? If you can live with that, then give it a go. You can always setup other git remotes for GitHub and / or Bitbucket as well, in addition to a Dropbox remote, if you worried about syncing issues (although you'd obviously have to manually push / pull to these).