I have:
folder_a/app_1.0
folder_b/app_1.1
And let's just say I'm working off of the master branch in both folders/repos.
How can I merge the branches together?
Added the source repository as a remote, by hitting the Settings button and adding the source repository. Branches from both repository now show in the branch list. I used the merge tool to merge a branch from the source repository to my new destination repository's branch. Commit the changes in my branch.
To combine two separate Git repositories into one, add the repository to merge in as a remote to the repository to merge into. Then, combine their histories by merging while using the --allow-unrelated-histories command line option.
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
You must pull the commits from one repository into the other, do the merge, then pull back into the first (if you want both repositories to contain all the commits).
# 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
# 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
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