Upgrade to Pro — share decks privately, control downloads, hide ads and more …

[GO1] Combining two Git repositories

[GO1] Combining two Git repositories

Avatar for hoangthienan

hoangthienan

August 03, 2018

Other Decks in Technology

Transcript

  1. 1 Mirroring a repository https://help.github.com/articles/duplicating-a-repository/ You must create the new

    repository on GitHub. In these examples, go1hub/util git clone --bare [email protected]:go1com/util.git cd util.git git push --mirror [email protected]:go1hub/util.git cd .. rm -rf util.git
  2. 2 Merging two Git repositories cd util_core git remote add

    util [email protected]:go1hub/util.git git fetch util git merge --allow-unrelated-histories util/master # or whichever branch you want to merge git remote remove util If you want to merge go1hub/util into go1hub/util_core The --allow-unrelated-histories parameter only exists since git >= 2.9
  3. 3 Combining two Git repositories git clone [email protected]:go1hub/util.git git clone

    [email protected]:go1hub/util_core.git cd util_core git remote rm origin git remote add origin [email protected]:go1hub/util.git git checkout master git branch -m master-holder git fetch git checkout master git pull origin master git rm -rf * git commit -m "Delete all the things." git merge master-holder --allow-unrelated-histories git push origin master Preserve all commits of both repositories, but replace everything from go1hub/util with the contents of go1hub/util_core https://gist.github.com/msrose/2feacb303035d11d2d05