0

I have a master branch and release branches in my git repository which is hosted on bitbucket. I got a merge conflict when I merged release branch r1 into master. The merge conflict was only due to a read me text file. I want to keep the readme file of r1 and reject the one in master.

I fixed the conflict and got an error when I pushed the merged code - "branch can only be modified through pull requests". I know this happens because we are not allowed to push directly into master. How do I merge r1 into master in this case ?

Erran Morad
  • 4,563
  • 10
  • 43
  • 72
  • 1
    why not merge master to r1 and then raise a PR ? – karthick Nov 14 '19 at 20:30
  • @karthick - I am new to git and not sure how the merging would work in that case. Would r1 changes be replaced by old master code ? I would like to keep only the readme from r1 and reject the readme which is in master. – Erran Morad Nov 14 '19 at 20:52

1 Answers1

0

You should to update the r1 branch with master. And then merge r1 into master using "Pull Request".

There are two ways to update r1:

  1. Merge master into r1

         git checkout r1 // checkout to branch r1
         git fetch origin master // fetch the latest version of master from origin
         git merge origin/master // merge the latest version of master into r1 branch
         git push // push new version of r1 to remote repository
    
  2. Rebase r1 on master

         git checkout r1 // checkout to branch r1
         git fetch origin master // fetch the latest version of master from origin
         git rebase origin/master // rebase r1 branch on the latest version of master
         git push --force // push new version of r1 to remote repository
    

    why --force? see here https://stackoverflow.com/a/8940299/5599567)

Anton Novik
  • 1,768
  • 1
  • 19
  • 31