Merging two git repositories

Aus Wiki
Wechseln zu: Navigation, Suche

You have two repositories, "Source" and "Target". It has somehow become superfluous to keep Source in a separate git repository and now you want to merge Source's content including the history into repository "Target".

  • clone "Source" repo:
git clone
  • rename master branch to "Source":
cd Source/
git branch master -m Source
  • re-configure the remote "origin" to be the "Target" repository:
git remote rm origin
git remote add origin
  • push "Source" branch to Target repo:
git push -u origin Source
  • switch to Target's master branch and merge Source into it:
git pull
git checkout master
git merge Source
  • finally, push the merged repository back to the Target remote:
git push
Meine Werkzeuge