Git和Dropbox可以一起使用吗?


当前回答

我不认为使用Git和Dropbox是正确的选择……想想两者的特点:

Git:

允许您拥有一个中央存储库 允许您使用自己的更改拥有自己的存储库 允许您从中央存储库发送和接收更改 允许多人更改相同的文件,他们合并他们或要求你合并他们,如果它不能这样做 web和桌面客户端是否允许访问中央存储库

Dropbox:

将所有内容保存在中央存储库中 允许您在服务器中拥有自己的文件版本 强制您从中央存储库发送和接收更改 如果多人更改相同的文件,第一个提交的文件将被稍后提交的文件所取代,并且不会发生合并,这很麻烦(这肯定是它最大的缺点) 具有web和桌面客户端以允许访问中央存储库。

如果你担心泄露你的文件,为什么不加密呢?然后你就可以得到Dropbox to Git的最大优势,那就是拥有公共和私人文件……

其他回答

在MacOS上,你也可以停止Dropbox,进行更改,然后重新启动Dropbox。 我正在使用以下组合,我很满意:

在这两个(本地git托管项目目录和位于Dropbox上的远程git存储库)中运行以下命令来禁用自动打包(这是Dropbox同步的主要问题)

git config --global gc.auto 0

然后不时地,压缩存储库dropbox禁用。例如,每当我发布应用程序的新版本时,我都会在bash-build-脚本中执行以下操作。

osascript -e "tell application \"Dropbox\" to quit"

# Compress local
git gc --prune=now; git repack -a -d

# Compress remote
REPOS_DIR_REMOTE=`git remote get-url --push origin`
cd "${REPOS_DIR_REMOTE}"
git gc --prune=now; git repack -a -d

osascript -e "tell application \"Dropbox\" to launch"
osascript -e "display notification with title \"Compress Done\""

我认为Dropbox上的Git很棒。我一直在用它。我有多台电脑(两台在家里,一台在公司),我把Dropbox作为一个中央的存储库。因为我不想把它托管在公共服务上,而且我也没有可以通过SSH访问的服务器,Dropbox通过在后台同步来解决这个问题(非常快)。

设置是这样的:

~/project $ git init
~/project $ git add .
~/project $ git commit -m "first commit"
~/project $ cd ~/Dropbox/git

~/Dropbox/git $ git init --bare project.git
~/Dropbox/git $ cd ~/project

~/project $ git remote add origin ~/Dropbox/git/project.git
~/project $ git push -u origin master

从那里,你可以克隆~/Dropbox/git/项目。git目录(无论它是否属于你的Dropbox帐户或在多个帐户之间共享)并执行所有正常的git操作-它们将自动同步到你所有的其他机器。

我写了一篇博客文章“关于版本控制”,其中介绍了环境设置背后的原因。它基于我的Ruby on Rails开发经验,但实际上它可以应用于任何东西。

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.

正确的方法是使用git-remote-dropbox: https://github.com/anishathalye/git-remote-dropbox

在Dropbox中创建自己的裸回购会导致很多问题。Anish(库的创造者)解释得很好:

The root cause of these problems is that the Dropbox desktop client is designed for syncing files, not Git repositories. Without special handling for Git repositories, it doesn’t maintain the same guarantees as Git. Operations on the remote repository are no longer atomic, and concurrent operations or unlucky timing with synchronization can result in a corrupted repository. Traditional Git remotes run code on the server side to make this work properly, but we can’t do that. Solution: It is possible to solve this properly. It is possible to use Git with Dropbox and have the same safety and consistency guarantees as a traditional Git remote, even when there are multiple users and concurrent operations! For a user, it’s as simple as using git-remote-dropbox, a Git remote helper that acts as a transparent bidirectional bridge between Git and Dropbox and maintains all the guarantees of a traditional Git remote. It’s even safe to use with shared folders, so it can be used for collaboration (yay unlimited private repos with unlimited collaborators!). With the remote helper, it’s possible to use Dropbox as a Git remote and continue using all the regular Git commands like git clone, git pull, and git push, and everything will just work as expected.

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

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

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