70 likes | 83 Views
Sometimes you may need to merge git repositories. Here are the steps to do it.#git #merge #software <br><br>Visit https://fedingo.com/how-to-merge-two-git-repositories/
E N D
Go to Repo Let us say you have two repositories repoA and repoB and you want to merge repoA into repoB. First, you need to navigate to repository into which you will be merging the other repository. That is repoB in our case. $ cd path/to/repoB
Add Remote URL From repoB, you need to add remote URL to the other repository that you want to merge, that is, repoA. $ git remote add repoA /path/to/repoA Now you can use repoA identifier to access the repoA’s contents.
Fetch RepoA Then you need to download repoA into repoB using git fetch command. $ git fetch repoA --tags
Merge repositories Merge the master branch of repoA with the master branch of repoB. It is important to use –allow-unrelated-histories option so that the histories of neither repository is disturbed. $ git merge --allow-unrelated-histories repoA/master Please note, –allow-unrelated-histories option exists only since git >=2.9. If you want to merge another branch of repoA you need to specify as shown below. Replace <branch_name> with the branch name that you want to merge. $ git merge --allow-unrelated-histories repoA/<branch_name> If you want to merge repoA with another branch of repoB, check out to that branch first before you run the above git merge command.
Remove Remote Handle Finally, remove the remote handle. $ git remote remove repoA If you want to put repoA into a subdirectory, then run the following command before you run the above command to merge repoA with repoB. $ cd path/to/repoA $ git filter-repo --to-subdirectory-filter repoA
Thank You Visit for details https://fedingo.com/how-to-merge-two-git-repositories/