Hacky way (let me know if you know better one)
Let's say you have repo Main and repo Proto, you want to put your Proto under Main, so folder structure will be the following:
|-SRC
|---proto
and you also want to preserve commit history, so everybody can see what you were doing while developing proto, sounds like pretty easy task. The easiest way is to create folder structure similar to Main repo SRC\proto and start working using is as a root, but if you like me, you didn't think about this beforehand, so you path would be harder:
- create orphan branch in you Proto repo
$ git checkout --orphan tmp - create folder structure similar to Main repo (
SRC\proto)$ mkdir SRC\proto - commit this empty folders (dont forget to add .gitkeep since git doesn't track directories)
- rebase your
masterbranch ontotmp$ git checkout master; git rebase tmp - run nuclear command to move all your files from
./to./SRC/proto$ git filter-branch --tree-filter 'mv * ./SRC/proto; git mv -k * ./SRC/proto' HEAD- this command will move all files from root dir to sub-dir on every commit in the history and re-commit files, which should result in a new root dir for all files
- important caveat is that that command won't move files starting with
.like.editorconfigor.bowerrc, we will fix it in the next step- note that you don't want to move
.gitignorebut merge it with your another repo's one
- note that you don't want to move
- now add your
Protorepo as a remote to yourMainrepo$ git remote add proto ~/proto/.git- replace
~/proto/.gitto your local file system path to.gitfolder of yourprotorepository
- replace
- rebase on top of your main repo
masteryourproto/masterbranch
What is the last command? I tried
but I get
Thank you - Juan