简体   繁体   中英

what is the best practice to merge develop branch to master branch

We have two branches in the remote git repository: master branch and develop branch. When I merge develop branch into master branch, how can I avoid merging conflict? If I solve the conflict in the master branch, then I need to merge master branch back to develop branch to keep develop updated. I do not think it is a good practice. Can anyone help me with this?

My question is more on what the best practice to merge develop branch to master branch to keep master branch clean.

Thanks

My question is more on what the best practice to merge develop branch to master branch to keep master branch clean

You could follow gitflow, see detailed explanation here: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

In summary:

  • keep master insync with latest release
  • merge features branches to develop
  • merge hotfixes branches to develop and master
  • when creating a regular release (not hotfix), create a release branch from develop and merge to master when releasing

I dont think there is anything wrong with the way you suggested. There is no way to 'sync' branches. I've used this method:

(develop)$git merge master

Resolve conflicts then:

(develop)$git checkout master
(master)$git merge develop

There should not be any conflicts since you already resolved them, but if there are accept all changes from develop since they are the changes you want. (Not too clear about what happens here, would need to test again to be sure)

If you mess up do:

(either branch)$git reset --hard HEAD~1

Now your branch is right before you did the merge. If you did a rebase it would be harder to undo a mistake because it changes your git history.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM