Git - Migrating code from one repository to another
Migrating code from one repository to another
Use-case: Migrating code from an old repository to a new repository. And you want to retain history along the way; to make it easier to pull changes over later.
> git remote add original ssh://git@git.forge.lmig.com:7999/pagro/renters-api-sb2.git
> git pull original feature/migrate-to-ocf --allow-unrelated-histories
It adds another remote (which I called original) to your repository. We prepped a branch over in the old application with the changes we thought may need to be pulled (feature/migrate-to-ocf).
We then pulled those changes over to the OCF application with the format git pull <remote name> <branch name>
This command is very similar to git pull origin main
but with a different remote and branch.
The flag --allow-unrelated-histories
was used as the new application had some baseline files/commits that the cloudforge market place already commited. This allowed us to work through the problem.
As changes were done in renters, instead of having to manually make the changes in two places; now the team can manually run git pull original develop to continue pulling in the latest changes with minimal merge conflicts and manual intervention