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"
while executing git filter-branch --subdirectory-filter muDirectory -- --all
.
I need detailed guidance with step by step procedure to move all files from one repo to another. Would appreciate any help, Thanks in advance.
repoB
and add a new remote with repoA URL
(say, repoA
).branchA
) with repoA/master history
. RepoA
. Command git mv <src> <dest>
.branchA
. master
branch and merge branchA
branch. 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
Pull master branch of repoA
into a sub-directory named repoA
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With