AKZN Notes

Archives for My Lazy and Forgetful Mind

How to merge two git branches that are in different repos/folders?

Last Modified on

Combining two git repositories

Use Case

I have:

  • folder_a/app_A
  • folder_b/app_B

I want to merge app_B into app_A and keep all history.

How can I merge the branches together?

switch to repo A

cd folder_a

Add repo B as a remote repository

git remote add folderb /path/to/folder_b

Pull B's master branch into a local branch named 'b'

git pull folderb master:b

// for my project toko-online, stop at this step is sufficient

Merge b into A's master branch

git merge b

Switch to repo B

cd ../folder_b

Add repo A as a remote repository

git remote add foldera /path/to/folder_a

Pull the resulting branch into repo B's master branch

git pull foldera master:master

Taken from : https://stackoverflow.com/questions/3402599/how-do-you-merge-two-git-branches-that-are-in-different-local-repos-folders


Another tutorial to read :
Combining two git repositories
https://gist.github.com/msrose/2feacb303035d11d2d05#file-combining-git-repositories-md

Leave a Reply

Your email address will not be published.