从通用差异导入更改到git存储库 [英] Import changes into a git repository from universal diff

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

问题描述

我试图从一个源代码管理系统(专有的和复杂的)导入更改到一个git仓库。我现在正在通过运行一个脚本来完成这个任务,这个脚本简单地同步到每个修订版本并将其提交到git存储库,但由于各种原因,这已变得不可行。



对于每个版本,我可以得到一个描述变化的通用差异。对我来说,这似乎应该足以将历史记录导入git中,但我不能为了我的生活而弄清楚如何让git来做到这一点。它看起来像我在git-apply和git-fast-import之间需要一些东西。也许我应该从以前的版本和差异构造文件内容,然后使用git-fast-import?或者我应该把diff作为一个git补丁格式化,保存为一个文件,然后使用git-apply?



任何人对我有任何好点子?



编辑:同步和提交失败的原因有两个:

首先,服务器维护一个文件列表已编辑。与编辑文件同步不能自动轻松自动执行,因此我在更新时恢复了更改。我们有一个签入队列系统,它只允许你在没有任何人在你面前编辑任何相同的文件时签入。第二,所有的分支都存储在同一个仓库中,所有的分支都存储在同一个仓库中,我们大量使用分支。同步一切都很简单并且工作起来,只同步一个目录(我所在分支的目录)看起来很麻烦。如果我同步所有内容,其他分支会在我不希望它们成为时更新。这通常不会是一个问题,但我们有另一个工具,这使得事情...复杂。

解决方案

不知道你的各种各样的原因变得不可行,但是我已经在工作中成功地完成了这个确切的事情,所以我熟悉了这些陷阱。诀窍在于将上游保存在一个单独的分支中,这样您就可以始终执行同步并执行 git commit 而不会产生冲突。我使用我的主分支来达到这个目的。从功能分支中检入新功能的工作流程如下所示:


  1. git checkout master

  2. 同步到集中的VCS

  3. git add -A

  4. git commit -m从上游同步
  5. git合并功能

  6. 检入集中式VCS

  7. git checkout -b nextfeature



  8. 我不打算从上游获取每一个修订版本,但是您可以通过为每个上游修订版执行步骤2-4来完成。


    I'm trying to import changes from one source control system (proprietary and complicated) into a git repository. I'm doing this currently by running a script that simply syncs to each revision in order and commits this to the git repository, but for various reasons this has become unworkable.

    For each revision, I can get a universal diff describing the change. To me it seems that this should be enough to import history to git, but I can't for the life of me figure out how to get git to do this. It looks like I need something in-between git-apply and git-fast-import. Perhaps I should construct the file contents from the previous version and the diff, then use git-fast-import? Or perhaps I should format the diff as a git patch, save it as a file, and use git-apply?

    Anyone got any good ideas for me?

    EDIT: The reason syncing and committing has become unworkable is twofold:

    First, the server maintains a list of files you have edited. Syncing with edited files can't be automated easily, so I revert my changes while updating. We have a checkin queue system that only allows you to checkin when nobody in front of you has any of the same files 'on edit' as you. So taking files 'off edit' to update creates a window where it looks like people can safely jump ahead of you.

    Second, all branches are stored in the same repository, and we make heavy use of branches. Syncing everything is easy and works, syncing just one directory (that of the branch I'm on) seems buggy. If I sync everything though, the other branches are updated when I don't want them to be. This normally wouldn't be a problem but we have another tool, which makes things... complicated.

    解决方案

    I don't know what your "various reasons this has become unworkable" are, but I have been doing this exact thing at work successfully for quite a while, so I'm familiar with the pitfalls. The trick is to keep your upstream in a separate branch such that you can always do a sync and a git commit without generating conflicts. I use my master branch for this purpose. My workflow to check in a new feature from a feature branch is something like this:

    1. git checkout master
    2. sync to centralized VCS
    3. git add -A
    4. git commit -m "Synced from upstream"
    5. git merge feature
    6. check in to centralized VCS
    7. git checkout -b nextfeature

    I don't bother getting every single revision from upstream, but you could do that by just doing steps 2-4 for each upstream revision.

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

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