简体   繁体   中英

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. We created our own git repository from this code which now has about 30 commits in branch master.

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.

This is what we did when we had to combine a fork that was under development for almost a year into our repo.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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