Skip to content

Instantly share code, notes, and snippets.

@hgraca
Last active April 12, 2023 16:49
Show Gist options
  • Save hgraca/dfffa1b4834a0b924825b6d3c726117e to your computer and use it in GitHub Desktop.
Save hgraca/dfffa1b4834a0b924825b6d3c726117e to your computer and use it in GitHub Desktop.
HOWTO merge repositories

HOWTO merge repositories

In the exporting repo (ex. legacy API into new monolith, the exporting repo is 'legacy API')

git checkout master
git pull
git checkout -b export
git mv public_html lib/legacy/api
git mv .gitignore lib/legacy/api
git mv bootstrap.php lib/legacy/api
git mv composer.json lib/legacy/api
git mv composer.lock lib/legacy/api
git mv Rollbar.php lib/legacy/api
git commit -m "Moved api to legacy folder for integration in monolith"

In the importing repo (ex. legacy API into new monolith, the importing repo is 'monolith')

git checkout master
git pull
git checkout -b import
git remote add api-local-repo ../api
git pull api-local-repo export --allow-unrelated-histories
git remote rm api-local-repo

After checking that everything is good, we need to push and eventually merge using the git browser UI

git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment