Git和Dropbox可以一起使用吗?


当前回答

现在是2015年,就在三天前,一个基于Dropbox API v2的新工具已经被创建出来,可以安全地在Dropbox上使用git。它针对API工作,而不是使用桌面客户端,并正确地处理多个同时推送到共享文件夹中托管的存储库。

一旦配置,它允许设置一个完全像其他git远程一样的git远程。

git clone "dropbox::/path/to/repo"
git remote add origin "dropbox::/path/to/repo"

其他回答

这个答案是基于Mercurial的经验,而不是Git,但这个经验告诉我们,如果你在不同的时间从不同的机器(对我来说是Mac、Unix和Windows)更新相同的基于Dropbox的存储库,那么以这种方式使用Dropbox会导致存储库损坏。

I don't have a complete list of the things that can go wrong, but here's a specific example that bit me. Each machine has its own notion of line-ending characters and how upper/lower case characters are handled in file names. Dropbox and Git/Mercurial handle this slightly differently (I don't recall the exact differences). If Dropbox updates the repository behind Git/Mercurial's back, presto, broken repository. This happens immediately and invisibly, so you don't even know your repository is broken until you try to recover something from it.

在用这种方法解决了一次混乱之后,我一直在使用下面的食谱,而且非常成功,没有任何问题的迹象。只需将存储库移出Dropbox。其他事情都用Dropbox;文档,JAR文件,任何你喜欢的东西。并使用GitHub (Git)或Bitbucket (Mercurial)来管理存储库本身。这两种工具都是免费的,所以不会增加成本,而且现在每种工具都发挥了自己的优势。

在Dropbox上运行Git/Mercurial除了风险什么都不会增加。不要这样做。

我把我的非github回购存储在Dropbox上。我遇到的一个警告是重新安装后的同步。Dropbox会先下载最小的文件,然后再下载较大的文件。如果你从晚上开始,周末后再回来,这不是问题:-)

我的帖子- http://forums.dropbox.com/topic.php?id=29984&replies=6

我们在共享文件夹上使用这种方法(在Dropbox中创建一个裸存储库)。

一小组开发人员可以从这个完全同步的存储库中提取数据,并创建一个本地克隆。一旦单位的功完成了,我们就回到原点。

我缺少的一件事是,在推送到原点时发送带有更改集信息的电子邮件的好方法。我们使用谷歌Wave来手动跟踪更改。

在我看来,Dropbox只适用于个人用途,因为你不想麻烦地获得一个中央回收主机。对于任何专业开发来说,你可能会制造更多的问题,而不是解决更多的问题,就像已经在帖子中多次提到的那样,Dropbox并不是为这个用例而设计的。也就是说,在没有任何第三方插件或工具的情况下,在Dropbox上转储存储库的一个非常安全的方法是使用捆绑包。我在我的.gitconfig中有以下别名以节省输入:

[alias]
        bundle-push = "!cd \"${GIT_PREFIX:-.}\" && if path=\"$(git config remote.\"$1\".url)\" && [ \"${path:0:1}\" = / ]; then git bundle create \"$path\" --all && git fetch \"$1\"; else echo \"Not a bundle remote\"; exit 1; fi #"
        bundle-fetch = "!cd \"${GIT_PREFIX:-.}\" && if path=\"$(git config remote.\"$1\".url)\" && [ \"${path:0:1}\" = / ]; then git bundle verify \"$path\" && git fetch \"$1\"; else echo \"Not a bundle remote\"; exit 1; fi #"
        bundle-new = "!cd \"${GIT_PREFIX:-.}\" && if [ -z \"${1:-}\" -o -z \"${2:-}\" ]; then echo \"Usage: git bundle-new <file> <remote name>\"; exit 1; elif [ -e \"$2\" ]; then echo \"File exist\"; exit 1; else git bundle create \"$2\" --all && git remote add -f \"$1\" \"$(realpath \"$2\")\"; fi #"

例子:

# Create bundle remote (in local repo)
$ git bundle-new dropbox ~/Dropbox/my-repo.bundle
# Fetch updates from dropbox
$ git bundle-fetch dropbox
# NOTE: writes over previous bundle. Thus, roughly equivalent to push --force --prune --all
$ git bundle-push

我也遇到过类似的问题,并为此创建了一个小脚本。我们的想法是尽可能简单地使用Dropbox和Git。目前,我已经快速实现了Ruby代码,不久将添加更多代码。

该脚本可在https://github.com/nuttylabs/box-git上访问。