php - Git branch overwrites master when merging without offering conflicts -


i have master project , 1 branch made it. when merge master branch, code in branch overwrites 1 in master, , insert different code branch in master, or @ least asked code want keep. here 1 simple example of how set everything:

mkdir project
cd project
git init

inside project directory have 1 file called index.php code:

<?php  /**  * master code.  */ class classname extends anotherclass {      function __construct(argument)     {         // master     } } 

then make branch:

git checkout -b my_branch

and put code inside index.php:

<?php  /**  * branch code.  */ class classname extends anotherclass {      function __construct(argument)     {         // branch     } } 

then checkout master , try merge:

git checkout master
git merge my_branch

and branch code override 1 master. in master have same code in branch. shouldn't git offer me chose code keep, or there way force ? if not, doing wrong ?

if make change in branch code:

class classname extends anotherclass => class classname extends myclass

then git recursive strategy merge, , take myclass branch , keep else master.

i not know if showing examples, let me try explain situation once again, please bare me:

1) have code in master not exists in branch.
2) have code in branch not exists in master.

how should deal , not lose different codes in both master , branch ? if can not happen on clean, planned way, can @ least force git ask me want differences ? can mange make branch override master, , bad.

i confused. thanks

merging branch means want add changes suggested branch. can not selectively merge branch. get's merged whole.

to see diff b/w 2 branches reviewing before merging, run

git diff master my_branch

if don't feel code in my_branch standards or errorenous, don't merge it.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -