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?
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
:
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
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 )
You should resolve the conflicts in your release branch. There are two solutions to do so. The first one is to rebase your release branch on top of master, but you will have to force push, so you need to be sure that you'll not override someone else commit:
git checkout r1
git fetch origin master
git rebase origin/master
Resolve your conflicts, then
git push -f
Otherwise you merge master in release, you resolve your conflicts and then you push.
Once the conflicts are resolved, you can create a pull request to merge release in master.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.