I want to move all my files from Git Repo A to Git Repo B with complete history. Git B already contains another project files. I tried several ways such as
How to move files from one git repo to another (not a clone), preserving history
How to move files from one git repo to another preserving history using `git format-patch`and `git am`
I tried executing all the commits via terminal. But I am getting
"git filter-branch fatal:myDirectory/: 'myDirectory' is outside repository Could not get the commits"
git filter-branch --subdirectory-filter muDirectory -- --all
repoBand add a new remote with
git mv <src> <dest>.
masterbranch and merge
Follow the commands:
# go into repoB master branch $ git remote add repoA <repoA-url> $ git remote -v # confirm repoA is added named 'repoA' $ git fetch repoA $ git checkout -b branchA repoA/master $ git mv <folder/file> repoA/<folder/file> # repeat untill all files/folders are moved $ git commit -am 'Moved repoA folder/file into repoA dir' $ git checkout master $ git merge branchA $ git add . $ git commit -m 'Added repoA into repoA directory' $ git push origin master
Git Subtree: You can do this using git subtree also:
$ git subtree add --prefix=repoA/ <repoA-url> master
master branch of repoA into a sub-directory named