简体   繁体   English

合并来自git存储库外部的更改

[英]Merging in changes from outside a git repository

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. 在我的结尾,我正在跟踪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. 当我收到他更新的代码时,通常采用zip文件的形式。 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. 如果我只是将文件解压缩到我的git工作文件夹中,git认为每个文件都已更改,大概是因为统计信息已更改。

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. 由于它是Powerbuilder项目,因此大多数文件都是二进制文件。

Thanks! 谢谢!

The binaries, if stored in Git, are bound to create a new version (ie to be taken into account at the next commit). 如果存储在Git中,二进制文件必然会创建一个新版本(即在下一次提交时要考虑)。
So: do you need those binaries, or can you rebuild them ? 所以:你需要那些二进制文件,还是可以重建它们?

As for the sources, in Git, SHA1 is king , and 至于消息来源,在Git中, SHA1是王者 ,而且 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. 使用像WinMerge这样的工具来检测基于内容的更改,合并它们,然后只提交实际演变的文件。
    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. 感谢rq指出时间戳不是SHA1计算的一部分。 Only the: 只有:

  • type 类型
  • size 尺寸
  • content of a blob blob的内容

are part of SHA1 computation : SHA1计算的一部分: 替代文字
(source: alexgirard.com ) (来源: alexgirard.com

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. 但是,当将外部管理的大量文件导入到git存储库时,您可能会冒险将新文件添加到git管理的目录中,更改其内容,从而更改其SHA1密钥,即使旧的git管理文件未更改。
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. 这意味着如果这些新文件只是临时文件或应该忽略/重新创建/重新生成的文件,那么树中的很多更改都是​​人为的。

替代文字
(source: alexgirard.com ) (来源: alexgirard.com

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管理的文件集之间的变化,并判断它是否必须是git工作目录的一部分。

this, altho not entirely sure a good idea, is what i'm thinking of doing in almost the same situation: 这个,不完全肯定是一个好主意,是我在几乎相同的情况下想做的事情:

what about basically maintaining a repo for them? 基本上为他们维护回购怎么样?

any changes you receive get placed in their repo and committed. 您收到的任何更改都会被归入其回购并提交。 then merge their repo, which would be a tracked remote, into yours when you need to? 然后在需要的时候将他们的回购合并到您的仓库中?

检查contrib/fast-import/import-zips.py是否contrib/fast-import/import-zips.py您的需求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM