Git与Dropbox [英] Git with Dropbox

查看:131
本文介绍了Git与Dropbox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用git半年左右,我不知道我是否完全使用git。

首先,我一直在试验使用Dropbox,我觉得如果我可以将它融入我的工作流程中,这将非常棒,因为Dropbox非常方便。


  1. 我有一台台式机和一台笔记本电脑。
    都有dropbox。

  2. 我使用
    来初始化我的Dropbox回购站,执行 git init --bare 。然后在我的桌面的post-commit脚本中

    我有一个 git push --mirror
    dropbox

通过这种方式,我的桌面和Dropbox将始终完全镜像,这是一件好事。



我真正的问题是:我应该如何设置我的笔记本电脑?
我一直听到一些建议:


  1. 从我的桌面上拉出,以便我的
    笔记本电脑的原点是桌面。

  2. 直接从保管箱中取出,这样我的
    笔记本电脑的原点就是保管箱。

我一直在做第二,我不知道我是否做对了。
我的工作流程包括:


  1. 每当我在我的笔记本电脑上时,我都会进行git pull(因为笔记本电脑的原点是dropbox, Dropbox更新本身)

  2. 然后,当我检查从保管箱到本地分支的分支。

  3. 在完成工作后,我承诺。

  4. 这是我感到困惑的地方:我是否应该将-mirror放入我的Dropbox回购站(我的笔记本电脑的回收站)?我在这方面遇到了一些困难:有时Dropbox不能很好地同步,等等。

目前,做一个<$ c $我的笔记本电脑上执行 git push --mirror origin 后,我的桌面上出现了git branch -r 不显示我最近的笔记本电脑提交。有人可以告诉我为什么吗?



我提到从我的桌面直接拉,因为这样我总是可以初始化拉,我100%确信同步完成。使用Dropbox我永远无法100%确定更新是否已经推送到保管箱服务器。

如果你想要添加一个中间回购容器,Dropbox可以提供:


  1. 您可以使用 格式 : :它只生成一个只有一个文件的裸回购(意味着Dropbox更有可能将其正确地同步到任何一台计算机:它只是复制一个文件,而不是整个结构你不知道你会得到什么样的东西)。

  2. 您的保存(再次,每次保存一个文件,容易从另一侧拉回来完成所做的事情)。

    在来源(笔记本电脑或台式机)和日期之后命名您的增量。

    基本上,你会从任何xxx中拉.bundle你还没有拉动过。


该模式允许:


  • 简化同步过程(一个或很少的文件)
  • 快速保存过程 缩放:如果有多个actor,即多个人正在更新同一个分支,则可以通过引用他们捆绑使用不同的远程名称(因为每个捆绑包都是裸露的回购库,您可以从中取回)。


I have been using git for half a year or so and I don't know whether I am using git fully.

First of all, I have been experimenting with dropbox and I feel that if I can incorporate it into my work flow, it would be really great since dropbox is pretty convenient.

  1. I have a desktop, and a laptop. Both have dropbox.
  2. I initialized my dropbox repos by doing a git init --bare. And then in my Desktop's post-commit script, I have a git push --mirror dropbox.

This way my desktop and dropbox will always be completely mirrored, which is a good thing.

My real question is: How should I set up my laptop? I have been hearing a few suggestions:

  1. Pull from my desktop, so that my laptop's origin is desktop.
  2. Pull directly from dropbox so that my laptop's origin is dropbox.

I have been doing number 2, and I don't know if I am doing the right thing. My work flow includes:

  1. Everytime I am on my laptop, I do a git pull (since laptop's origin is dropbox and dropbox updates itself)
  2. Then when I check out a branch from dropbox to a local branch.
  3. After I am done with work, I commit.
  4. This is where I am confused: Should I push --mirror to my dropbox repos (my laptop's origin repos) too? I am getting some difficulties in this area: Sometimes dropbox doesn't sync quite well, etc

Currently, doing a git branch -r on my desktop after doing git push --mirror origin on my laptop doesn't show my recently laptop commits. Can someone tell me why?

I mentioned pulling from my desktop directly because that way I can always initialize the pull and I am 100% confident that the sync is done. With dropbox I can never be 100% sure whether the update has been pushed to the dropbox server

解决方案

If you want to add an intermediate repo container, Dropbox is fine provided:

  1. You use the git bundle format: it generates a bare repo with only one file (meaning Dropbox is more likely to correctly sync it to any of your computers: it is just about copying one file, not "the whole structure" from which you are not sure you will get everything back).

  2. You are using incremental bundle for each of your saves (again, one file per save, easy to pull from on the other side to get back what has been done).
    Name your increment after the source (laptop or desktop) and with the date.
    Basically, you will pull from any xxx.bundle you haven't pulled yet.

  3. You regularly clean all the intermediate incremental bundles, replacing it with a full bundle from whatever source is the most up-to-date

That model allows for:

  • simple sync process (one or very few files)
  • quick saving process (with incremental bundles)
  • scaling: if there is more than one actor, i.e. if several people are updating the same branch, you can isolate their contributions when pulling from them by referencing their bundles using a different remote name (since each bundle is a bare repo from which you can pull).

这篇关于Git与Dropbox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆