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!
Asked
Active
Viewed 294 times
0

Jeff
- 1,152
- 5
- 14
- 27
-
1Check out this previous issue on branch changes http://stackoverflow.com/questions/7175869/managing-hotfixes-when-develop-branch-is-very-different-from-master – DanielGaffey Apr 04 '13 at 02:05
1 Answers
1
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
).

GoZoner
- 67,920
- 20
- 95
- 145