Home > OS >  How to sync two branches in different repositories
How to sync two branches in different repositories

Time:11-25

I have a repo say A with branch x and a repo B with branch y. I want to clone the content from branch x of repo A to branch y of repo B. I do not care about the commit history of either repositories. Currently, I am copying the content from one repo to another.

Is there any functionality provided by Git to perform this task?

CodePudding user response:

The following is a decent place to start, in my opinion. It also helps to preserve history, which is helpful in the vast majority of circumstances. Using Git remote will assist you in completing the task by constructing a tunnel between your two Git repositories. The commands listed below should be followed. repo_B/<my_branch> will have everything from both repo_A/<my_branch> and repo_B/<my_branch>, as well as their histories.

cd repo_B # Assuming you are already in the parent of repo_B
git checkout <my_branch>
git remote add repo_a_remote **URL_OF_REPO_A**
git fetch repo_a_remote
git merge repo_a_remote/<my_branch> --allow-unrelated-histories
git remote rm repo_a_remote

For a more in-depth look at the above's commands. Here is some documentation to consider:

CodePudding user response:

You must diff and merge manually.

You can use Beyond Compare 4 for this task. I don't recommend you use your current working way with git.

  • Related