Skip to content

Instantly share code, notes, and snippets.

@gghughunishvili
Last active August 12, 2017 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gghughunishvili/41bca7d789e3d159feff4b24f8c17d48 to your computer and use it in GitHub Desktop.
Save gghughunishvili/41bca7d789e3d159feff4b24f8c17d48 to your computer and use it in GitHub Desktop.
Move one repository into another (merging) without losing history
# Caution: new repo should be empty otherwise you lose new repo data!
git clone --mirror <url_of_old_repo>
cd <name_of_old_repo.git>
git remote add new-origin <url_of_new_repo>
git push new-origin --mirror
# if you want merge two repositories you should use the following commands
# merging project-a into the project-b
cd <path_to_project_b>
git remote add project-a <url_of_project_a>
git fetch project-a
git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge
git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment