Skip to content

Instantly share code, notes, and snippets.

@razorcd
Last active January 14, 2018 20:48
Show Gist options
  • Save razorcd/4e28febe4897cf1bd5ff9b30d31c3913 to your computer and use it in GitHub Desktop.
Save razorcd/4e28febe4897cf1bd5ff9b30d31c3913 to your computer and use it in GitHub Desktop.
Git Subtree merging while keeping the commits
# add remote repo from another filepath:
git remote add -f springBootSippetsFullRepo ../1/spring-boot-snippets-full-folder
# merge to current master (will not messup original files)
git merge -s ours springBootSippetsFullRepo/master
# move new repo in a subfolder:
git read-tree --prefix=springBootSnippets -u springBootSippetsFull/master
# comit new folder:
git commit -v -m "merges springBootSnippets as subfolder"
# Notice that the new folder has no .git folder anymore.
# Remember that subtree merge will not include any files that are not in the commits.
# So files that are in .gitignore will not be copied. You might want to copy these manually. (E.g. IDE config files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment