Skip to content

Merge

how to merge

#edit conflict file
git add <file-path>
git commit -m "Updated"
git push

in conflict state accept theirs

git checkout --theirs <file-path>
git add <file-path>

resolve conflict

git switch master
git pull
git switch my-branch
git rebase master

refusing to merge unrelated histories

$ git merge azure/main
fatal: refusing to merge unrelated histories
  • two repos do not have shared histories

  • force merge: git merge azure/main --allow-unrelated-histories

  • then solve the conflicts: git add xxx; git commit yyy

  • not good: will include all commits from the source repo

  • use cherry-pick?