如何配置 Git 以便在 Dropbox 中使用它? [英] How to configure Git for using it with Dropbox?

查看:28
本文介绍了如何配置 Git 以便在 Dropbox 中使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 git 半年左右了,我不知道我是否完全使用了 git.

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

首先,我一直在尝试使用 dropbox,我觉得如果我能将它融入我的工作流程中,那就太好了,因为 dropbox 非常方便.

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. 我有一台台式机和一台笔记本电脑.两个都有保管箱.
  2. 我通过以下方式初始化了我的保管箱存储库做一个 git init --bare.进而在我桌面的提交后脚本中,我有一个 git push --mirror保管箱.
  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.

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

  1. 从我的桌面上拉,以便我的笔记本电脑的起源是台式机.
  2. 直接从 Dropbox 拉取,以便我的笔记本电脑的起源是 Dropbox.

我一直在做第 2 件事,但我不知道我做的是否正确.我的工作流程包括:

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

  1. 每次使用笔记本电脑时,我都会执行 git pull(因为笔记本电脑的起源是 Dropbox,而 Dropbox 会自行更新)
  2. 然后,当我将一个分支从 dropbox 签出到本地分支时.
  3. 完成工作后,我承诺.
  4. 这就是我感到困惑的地方:我也应该将 --mirror 推送到我的保管箱存储库(我的笔记本电脑的原始存储库)吗?我在这方面遇到了一些困难:有时 Dropbox 不能很好地同步,等等

目前,在我的笔记本电脑上执行 git push --mirror origin 后,在我的桌面上执行 git branch -r 不显示我最近的笔记本电脑提交.谁能告诉我为什么?

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?

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

推荐答案

如果你想添加一个中间 repo 容器,Dropbox 提供:

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

  1. 您使用 git bundle 格式:它生成一个只有一个文件的裸仓库(这意味着 Dropbox 更有可能将其正确同步到您的任何计算机:它只是复制一个文件,而不是整个结构",您不确定从中可以获得所有.

  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).

您正在为每次保存使用增量包(同样,每次保存一个文件,易于从另一侧拉取以恢复已完成的工作).
以来源(笔记本电脑或台式机)和日期命名您的增量.
基本上,您将从任何尚未提取的 xxx.bundle 中提取.

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.

您定期清理所有中间增量包,将其替换为来自任何最新来源的完整包

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

该模型允许:

  • 简单的同步过程(一个或很少的文件)
  • 快速保存过程(使用增量包)
  • 缩放:如果有多个参与者,即如果有几个人正在更新同一个分支,您可以通过使用不同的远程名称引用他们的包来隔离他们的贡献(因为每个包都是一个裸仓库,您可以从中拉取).
  • 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天全站免登陆