简体   繁体   English

将来自同一项目但完全独立的提交历史记录从一个git存储库合并到另一个

[英]Merge files from same project but completely independent commit history from one git repository into another

My team has been working on a project with another team. 我的团队一直在与另一个团队合作进行项目。 They have a remote repository which my team was not initially given access to. 他们有一个远程存储库,最初我的团队没有访问这些存储库。 Instead, we were given a zip file containing the code but none of the commit history. 相反,我们得到了一个包含代码的zip文件,但没有提交历史记录。 We created our own git repository from this code which now has about 30 commits in branch master. 我们从此代码创建了自己的git存储库,该代码库现在在分支master中有大约30个提交。

Now, the other team have given us access to their repository and want us to create a new branch on their remote containing our changes, which they will later merge with theirs as they see fit. 现在,另一个团队已使我们能够访问其存储库,并希望我们在其远程上创建一个新分支,其中包含我们的更改,他们以后将在适当时将其与他们的合并。

What is the best way to accomplish this? 做到这一点的最佳方法是什么?

Maintaining the commit history from our repository would be nice, but isn't crucial. 从我们的存储库中维护提交历史记录会很好,但不是很关键。 Moving forward we will most likely be working exclusively off of their remote. 展望未来,我们很可能将完全不在他们的遥控器范围内工作。 I don't know exactly which commit the code they gave us was taken from, but could probably find out if it's useful. 我不知道他们提供给我们的代码是从哪个提交中提取的,但是可能会发现它是否有用。

I've tried adding their server as a new remote to my local repository and pulling in their code, but I haven't been able to wrap my head around how exactly to combine the two. 我曾尝试将他们的服务器添加为本地存储库的新远程服务器,并提取他们的代码,但是我还无法完全结合两者。 I've also considered just copying the files on top of a fresh clone from their repository and creating the branch from that, but I'm afraid that will cause us to lose the changes they have made. 我还考虑过仅从其存储库中复制一个新克隆上的文件,然后从中创建分支,但是恐怕这会导致我们丢失所做的更改。

Your original idea is the way to go. 您最初的想法是要走的路。

  1. remove the current remote 删除当前遥控器
  2. add their remote in your repo 将他们的遥控器添加到您的仓库中
  3. checkout your master as a new branch and push it to upstream 将您的主人作为新分支签出并将其推送到上游

If necessary delete your master and fetch and pull their master branch. 如有必要,请删除您的master并获取并拉出他们的master分支。

This is what we did when we had to combine a fork that was under development for almost a year into our repo. 这是我们不得不将已经开发了将近一年的分叉组合到我们的仓库中时所做的。

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

相关问题 有没有一种方法可以将提交历史从SVN存储库合并到Git分支? - Is there a way to merge the commit history from an SVN repository to a Git branch? 从 git 存储库中完全删除文件及其历史记录 - Remove Files completely from git repository along with its history 将提交从一个分支移动到具有几乎相同文件内容但完全不同的提交历史记录的分支 - Move commits from one branch to another with almost the same file contents but completely different commit history 如何从git历史记录中完全删除提交 - How to completely remove a commit from git history 从git历史记录中删除并完全删除提交 - Delete and completely remove the commit from git history 在一次提交中将主服务器从一个存储库合并到另一个存储库的主机 - Merge master from one repository to the master of another repository in one commit 从远程Git存储库中完全删除提交 - Completely remove a commit from remote Git repository Git:如何在不添加合并提交的情况下从另一个存储库中提取 - Git: How to pull from another repository without adding a merge commit Git:继续上一次提交的存储库历史记录 - Git: continue repository history from previous commit git从历史记录中删除合并提交 - git remove merge commit from history
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM