Alfonso Tesauro
Alfonso Tesauro

Reputation: 1792

Is it possible to merge two different git repositories of the same project?

I have been given a codebase (Xcode - Swift) by a client, in the form of a zip file, without any .git folder. As soon as I received it, I have initialised a new git repository and I am storing it on GitHub. I then started to work on it and make commits. Now finally, the client has succeeded to speak with the previous developer and this developer has given me the bitbucket credentials of the project, whose last commit makes it the same as the zip file I originally received. It would be very nice if I could merge the two repo, to continue working having all the previous commits that are on bitbucket, and the option to ascertain, via "show last change for line" for example, if some part of the code was written by the previous developer or by me. Can anybody point me in the right direction ? any help is greatly appreciated. Thanks

Upvotes: 1

Views: 62

Answers (1)

eftshift0
eftshift0

Reputation: 30327

On the repo where you started tracking the client code, add a remote to the git repo that you got access to... let's call it client remote. If I understand correctly, the first revision of your main branch will match client/main. So, run a rebase like this:

git branch temp main # create a backup branch, just in case
git rebase --onto client/main id-of-first-revision-on-local-branch-main main

That way you are asking to move all your commits after the first revision of the project on top of the original branch that you didn't have access to before.

Upvotes: 1

Related Questions