Another approach:
All the answers so far, including @Dan answer which is the most popular, address the idea of using Dropbox to centralize a shared repository instead of using a service focused on git like github, bitbucket, etc.
But, as the original question does not specify what using "Git and Dropbox together effectively" really means, let's work on another approach:
"Using Dropbox to sync only the worktree."
The how-to has these steps:
inside the project directory, one creates an empty .git
directory (e.g. mkdir -p myproject/.git
)
un-sync the .git
directory in Dropbox. If using the Dropbox App: go to Preferences, Sync, and "choose folders to sync", where the .git
directory needs to get unmarked. This will remove the .git
directory.
run git init
in the project directory
It also works if the .git
already exists, then only do the step 2. Dropbox will keep a copy of the git files in the website though.
Step 2 will cause Dropbox not to sync the git system structure, which is the desired outcome for this approach.
Why one would use this approach?
The not-yet-pushed changes will have a Dropbox backup, and they would be synced across devices.
In case Dropbox screws something up when syncing between devices, git status
and git diff
will be handy to sort things out.
It saves space in the Dropbox account (the whole history will not be stored there)
It avoids the concerns raised by @dubek and @Ates in the comments on @Dan's answer, and the concerns by @clu in another answer.
The existence of a remote somewhere else (github, etc.) will work fine with this approach.
Working on different branches brings some issues, that need to be taken care of:
One potential problem is having Dropbox (unnecessarily?) syncing potentially many files when one checks out different branches.
If two or more Dropbox synced devices have different branches checked out, non committed changes to both devices can be lost,
One way around these issues is to use git worktree to keep branch checkouts in separate directories.