简体   繁体   中英

Merging a hotfix branch into master but not dev

In my project, I have two main branches: master and dev . I've been doing a lot of work on the dev branch as I finish up a new release. I have identified an issue in my current master branch that needs to be fixed. The only issue is, in my dev branch, I have completely overhauled that same file. When I make a hotfix branch, I usually merge it back into both master and dev . But in a situation like this, I think I would get lots of merge conflicts. Is it okay to simply merge this into master without merging it into dev ? Can I expect merge conflicts when I merge dev back into master ? Thanks!

It is fine not to merge it; but, it is also possible to merge and to resolve all the conflicts in the favor of the dev branch. By doing the merge, you maintain the similarity between the master and dev branches structure-wise. The procedure is:

$ git checkout dev
$ git merge hotfix
# conflicts arise, use `dev`
$ git checkout --ours -- <filename>  # --ours is the key.
$ git add <filename>
$ git commit ...

When you merge dev into master you might have conflicts but you will revolve them with --theirs (use the file from dev , not 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.

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