Skip to content

Instantly share code, notes, and snippets.

@xmzhao
Forked from smdabdoub/merge_git_repo_as_subdir
Last active September 16, 2019 08:14
Show Gist options
  • Save xmzhao/fa2d403eefd88d6fb4fb34d5343f9b7b to your computer and use it in GitHub Desktop.
Save xmzhao/fa2d403eefd88d6fb4fb34d5343f9b7b to your computer and use it in GitHub Desktop.
Merge one git repository into another repository as a sub-directory
# based on the following:
# http://saintgimp.org/2013/01/22/merging-two-git-repositories-into-one-repository-without-losing-file-history/
# http://blog.caplin.com/2013/09/18/merging-two-git-repositories/
git clone Task (保证在master)
git clone DopNluServer (保证在master)
cd Task
git remote add DopNluServer ../DopNluServer
git fetch DopNluServer
git checkout -b DopNluServer DopNluServer/master
mkdir DopNluServer
# '*' will cause git mv to fail because it cannot move DopNluServer into itself
git mv <list all files> DopNluServer
git commit -m "Moves all DopNluServer files into a single directory for merging back into Task"
git checkout master
git merge DopNluServer
# commit and push, and you're finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment