0

We are following template branch approach wherein the new feature branch is created from an empty (folder only) template branch (used for information code as we don't want the entire code base to be deployed).

The problem is that when we try to merge the release (having changes for current release) to the master branch (entire codebase), we always end up in merge conflict for the existing files. In case of merge conflict, I would like the changes in the release branch to be merged to the master branch, as I want the latest changes to be retained.

Is there any option to forcefully merge the changes in release branch to master without resolving the conflicts?

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34
Rahul Raj
  • 71
  • 6
  • Does this answer your question? [Git merge conflict to always take the newest file](https://stackoverflow.com/questions/7607125/git-merge-conflict-to-always-take-the-newest-file) – SwissCodeMen Sep 12 '20 at 21:57

1 Answers1

1
  1. git checkout master
  2. git merge -X theirs release
Adam Tang
  • 332
  • 2
  • 3
  • 1
    Be careful: `-X theirs` means take their *change* in a case of conflict, not take their *file* in such a case. – torek Sep 13 '20 at 01:34
  • 1
    I do not recommend `-X their`, When conflicts happened means that both are changing in the same block code, you don't know which one is updated or need to combine both. There're many useful tools help to resolved conflict. You should improve workflow to avoid conflict during merge – Rony Nguyen Sep 13 '20 at 15:07
  • Thanks Adam , Torek and Toan for your response! As per the admin settings, we cannot push directly to release or master branches and these 2 branches can only be modified using pull requests. As the release branch code moves to production thereby ,we need not worry if the file is forcefully merged to master (overwriting the conflicting changes in release branch to master).What are the limitations if I copy the master branch in feature and then force merge my changes in release branch to Feature(as per Adam's commands).I can then create a PR to merge feature to master again. – Rahul Raj Sep 13 '20 at 19:20
  • Hi Adam, when I am trying to merge the release branch to feature using the below command, I am getting the error message " merge: - not something we can merge " git checkout git merge -X theirs I tried the below command but the same error message git merge -s recursive -X theirs Please suggest. – Rahul Raj Sep 22 '20 at 19:06
  • First, please check if there is any typo in . Else, try `git checkout && git pull` `git checkout && git pull` `git merge -X theirs ` This ensures you have local knowledge of both branches before you merge them. Once again, be careful when using -X theirs. You want to know what you are doing. – Adam Tang Sep 23 '20 at 19:08