我有一个开发团队使用的远程存储库(源)和一个用于devops的目标远程存储库(目标)。大多数更改是在源存储库上进行的,但也有一些更改是在目标存储库上进行的。我正在使用本地存储库来合并两个远程存储库,然后将合并的代码推送到devops(目标)存储库。
我需要的是
这些是我一直使用的git命令,确信我们的策略正在按预期合并冲突,但我注意到在最近的冲突中,从目标存储库中提取的内容占了上风。
-- Cloning the origin repository
git clone <origin-repo-url>
-- Checking out the wanted branch
git checkout <branch-name>
-- Adding the destination remote repository
git remote add <dest-repo> <dest-repo-url>
-- Fetching/merging code from the destination repository
git pull -X ours <dest-repo> <dest-branch-name> --allow-unrelated-histories
-- Pushing the merged code to the destination repository
git push --force --tags <dest-repo> <origin-branch-name>:<dest-branch-name>