手动将更改导入存储库 [英] manually pulling changes into a repository

查看:88
本文介绍了手动将更改导入存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户使用我的应用程序和一个.git存储库的本地副本,她用它来恢复更改和测试补丁等。但是,她没有简单的方法将防火墙的最新更改安装到远程计算机上和其他规则。所以我想只要让他们下载一个新的,完整的.git库压缩。但是存储库是一个可以舒适地移动的大妈妈,所以我宁愿只是发送一个压缩的.git增量变化(对象,参考等)在她的本地.git目录中解压缩。



我已经尝试了以下工作流程(根据文件时间戳自动执行):


  1. 在她的.git / objects目录中获取最新的时间戳记
  2. 从我的.git目录创建一个zip文件从该时间戳开始的文件
  3. $
  4. 在客户的.git文件中解压缩zip(如果某些文件被覆盖,则无关紧要)

  5. code> git checkout -f master (或者他们需要的任何分支/标签)和 git clean -d -f

它工作正常,因为她的工作树和.git目录从不在本地修改,只从一个分支签出到标签或其他东西。但是文件时间戳很可能是不可靠的......也就是说,它可能会通过备份或其他方式获得 touch ed,所以我正在寻找更优雅的方式来创建此增量zip使用某种形式的提交。 所以,如果我从客户的本地.git文件获取信息,我如何以编程方式创建我的.git目录的增量zip文件?推测这与git在内部非常类似,以增量方式从远程获取内容。什么是选择正确的文件的算法?如何确定客户存储库中的基线提交以构建增量zip?

解决方案

为什么不使用 git format-patch 命令?或者 git包这里是一个例子怎么做。您的客户需要下载完整的压缩 .git 目录一次,之后他可以使用增量补丁。


I have a customer with my app and a local copy of its .git repository, which she uses to revert changes and test patches, etc. But there is no simple way she can pull a remote with the latest changes due to firewall and other rules. So I thought "just let them download a new, full .git repository zipped up". But the repository is a big mama to move around comfortably, so I would prefer to just send her a zipped up .git of incremental changes (objects, refs, etc) to be decompressed inside her local .git dir.

I've tried the following workflow (automated from within my software), based on the file timestamps:

  1. get the most recent timestamp in her .git/objects directory
  2. create a zip from my .git dir of files starting on that timestamp
  3. email zip file
  4. decompress zip inside customer's .git (it doesn't matter if some files are overwritten)
  5. git checkout -f master (or whatever branch/tag they need) and git clean -d -f

It works fine, since her working tree and .git directories are never modified locally, only checked-out from one branch to a tag or whatever. But file timestamps are definetly unreliable... ie it may all get touched by some backup or whatever, so I'm looking for a more elegant way to create this incremental zip using a commitish of some sort.

So, how could I programmatically create an incremental zip file of my .git directory given I have information from the customer's local .git? I guess this is very similar to what git does internally to pull things from remote incrementally. What's the algorithm to select the correct files? How do I determine the baseline commit from the customer's repository to build the incremental zip?

解决方案

Why not use git format-patch command? Or git bundle? Here is an example of how to do it. Your customer need to download full zipped .git directory only once with this, later he can use incremental patches.

这篇关于手动将更改导入存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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