合并来自git仓库之外的更改 [英] Merging in changes from outside a git repository

查看:96
本文介绍了合并来自git仓库之外的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与该国另一方的另一位开发人员一起工作,他们是我们项目的负责人,而且没有使用正式的版本控制系统。在我的最后,我正在用git跟踪所有的代码。我最近开始为主项目做出贡献,并希望能够跟踪其他开发人员的更新。



当我收到他更新的代码时,它是通常采用zip文件的形式。如果我简单地将文件解压缩到我的git工作文件夹中,git认为每个文件都已更改,可能是因为stat信息已更改。



我想看看是一种可以将我的工作副本旁边的新代码解压缩的方法,并且仅合并更改。什么是最好的方法来做到这一点?由于这是一个Powerbuilder项目,所以大部分文件都是二进制文件。



谢谢!

解决方案

如果存储在Git中,二进制文件必然会创建一个新版本(即在下一次提交时将被考虑)。

所以:你需要这些二进制文件,还是可以你重建它们?



至于源代码,在Git中, SHA1为王,自文件日期(时间戳)参与其计算以来的,因为外部集的文件在其内容(更多文件,临时文件,应该忽略的文件...)上可能有很大不同,最好是:


  • 在一个单独的目录中解压缩

  • 使用诸如 WinMerge 检测基于内容的更改,合并它们,然后仅提交实际执行的文件lly演变。

    您只需比较两组目录和文件:解压缩远程同事的开发以及当前正在工作的那一个。






感谢 rq 指出时间戳不是SHA1计算的一部分。
只有:


  • 类型

  • 尺码

  • blob的内容



SHA1计算替代文字http://alexgirard.com/git-book/assets/images/figure/object-blob.png



然而,当将大量外部管理的文件导入到git存储库时,即使旧的git托管文件没有更改,您也有可能将新文件添加到git托管的目录中,更改它们的内容,即SHA1密钥。

这意味着如果这些新文件只是临时文件或者应该被忽略/重新创建/重新生成的文件,那么树中的很多更改都是​​虚假的。



alt text http:// a lexgirard.com/git-book/assets/images/figure/object-tree.png



上述过程只是确保外部 em>方法来检测外部组文件和git管理的一组文件之间的变化,并判断它是否必须是git工作目录的一部分。


I'm working with another developer on the other side of the country who is the lead on our project, and isn't using a formal version control system. On my end, I'm tracking all of my code in git. I've recently started contributing to the main project, and would like to be able to track updates from the other developer as well.

When I receive his updated code, it's usually in the form of a zip file. If I simply unzip the file into my git working folder, git believes that every file has changed, presumably because the stat info has changed.

What I'd like to see is a way that I can unzip the new code alongside my working copy, and merge in only the changes. What's the best way to do this? As it's a Powerbuilder project, most of the files are binaries.

Thanks!

解决方案

The binaries, if stored in Git, are bound to create a new version (i.e. to be taken into account at the next commit).
So: do you need those binaries, or can you rebuild them ?

As for the sources, in Git, SHA1 is king, and since the date of the file (timestamps) is involved in its calculation, since the external set of files can be fairly different in its content (more files, temporary files, files that should be ignored, ...), it would be best to:

  • unzip in a separate directory
  • use a tool like WinMerge to detect changes based on the content, merge them, and then commit only the files that have actually evolved.
    You just compare the two set of directories and files: the one where you have unzipped the development of your far-away colleague, and the one in which you are currently working.

Thanks to rq for pointing out that timestamps are not part of SHA1 computation. Only the:

  • type
  • size
  • content of a blob

are part of SHA1 computation: alt text http://alexgirard.com/git-book/assets/images/figure/object-blob.png

However, when importing large set of files externally managed into a git repository, you risk adding new files into git-managed directories, changing their content, hence their SHA1 key, even though old git-managed files have not changed.
That means a lot of changes in tree are artificial if those new files are just temporary files or files that should be ignored/recreated/regenerated anyway.

alt text http://alexgirard.com/git-book/assets/images/figure/object-tree.png

The above process just ensure an external way to detect what has changed between an external set of files and a git-managed set of file and judge if it has to be part of the git working directory or not.

这篇关于合并来自git仓库之外的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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