相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- What is the tortoisehg gui equivalent of doing “hg
- How to use Mercurial from Visual Studio 2010?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is it possible to do a “destroy history” in TFS?
- Is there a version control system abstraction for
I didn't want to put all my projects under one Git repository, nor did I want to go in and run this code for every single project, so I made a Bash script that will automate the process. You can use it on one or multiple directories - so it can do the code in this post for you or it can do it on multiple projects at once.
I've been using Mercurial in the recommended manner and urge that you be cautious, especially if any of the machines differ. The Dropbox fora are full of complaints of mysterious filename case problems turning up spontaneously. Hg (and I presume Git) won't notice or complain during routine checkins and you'll only hear about the corruption when it complains of a corrupt repo when you try to use it for real. Bad news. Wish I could be more specific about the problem and its workarounds; I'm still trying to dig out from this mess myself.
With regards to small teams using Dropbox:
If each developer has their own writable bare repository on Dropbox, which is pull only to other developers, then this facilitates code sharing with no risk of corruption!
Then if you want a centralized 'mainline', you can have one developer manage all the pushes to it from their own repo.
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 directoryIt 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
andgit 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.Now in 2014, I have been using Git and Dropbox for about one year and a half without problem. Some points though:
git push
pushes to a remote repository, so that if it ever gets corrupted, I can easily recover it.C:\Users
withmklink /D link target
because some libraries were pointed to absolute locations.We use this method (creating a bare repository in Dropbox) on a share folder.
A small group of developers can pull from that bare synced repository and create a local clone. Once the unit of work is done, we push back to origin.
One thing I'm missing is a good way to have an e-mail sent with the change-set information once a push to origin occurs. We are using Google Wave to manually keep track of changes.