Skip to content

Instantly share code, notes, and snippets.

@betrcode
Created September 6, 2017 11:27
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 betrcode/1470a6c48da36740d5e0f6cbcd4de614 to your computer and use it in GitHub Desktop.
Save betrcode/1470a6c48da36740d5e0f6cbcd4de614 to your computer and use it in GitHub Desktop.
Merge Git Repositories and Preseve Commit History by Scott W Bradley
# ...First create a new empty repository on github named 'simpsons'...
# Clone all the repos to work with
$ cd ~/src
$ git clone git@github.com:scottwb/homer.git
$ git clone git@github.com:scottwb/bart.git
$ git clone git@github.com:scottwb/simpsons.git
# Copy over homer to simpsons
$ cd homer
$ git remote rm origin
$ mkdir homer
$ git mv *.* homer/.
$ git commit -m "Prepare homer to merge into simpsons"
$ cd ../simpsons
$ git remote add homer ~/src/homer
$ git pull homer master
$ git remote rm homer
$ cd ..
$ rm -rf homer
# Copy over bart to simpsons
$ cd bart
$ git remote rm origin
$ mkdir bart
$ git mv *.* bart/.
$ git commit -m "Prepare bart to merge into simpsons"
$ cd ../simpsons
$ git remote add bart ~/src/bart
$ git pull bart master
$ git remote rm bart
$ cd ..
$ rm -rf bart
# Push simpsons back upstream to github
$ cd simpsons
$ git push
@betrcode
Copy link
Author

betrcode commented Sep 6, 2017

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