5

I have a problem where my master changes are completely overwriting my changes in a development branch, instead of merging them.

I have a master and a development branch for a web application. I am currently working on features that will take a few weeks to implement, but at the same time other developers are continuously adding to master.

Let me use one file as an example, functions.php

I am making many lines of changes in the functions.php file within the dev branch.

Occasionally I switch to master using git checkout master and pull from the online using git pull origin master. This brings the team changes inline with my local dev.

Now, I want to introduce those changes into my functions.php file in dev branch while maintaining my work I have done thus far. So I checkout the dev branch and I run git merge master. The thing is, the functions file in master branch is COMPLETELY overwriting my functions file in dev branch.

Why?

To summarize my workflow:

git checkout master # Move to master branch
git pull origin master # Get down local changes, all along I have been working in dev and making dev progress
git checkout dev # move to dev branch
git merge master # attempt to align team changes to my dev branch

my files are overwritten, NOT merged.

Thank you, Simon

SimonDowdles
  • 2,026
  • 4
  • 24
  • 36

1 Answers1

2

Check your "config" file inside your ".git" folder of your local repository or global.
In that, if notes.mergeStrategy is configured to "theirs", then your changes will be overwritten. You just need to remove that configuration and everything will be fine.

Ref:

  1. https://git-scm.com/docs/git-config
  2. https://git-scm.com/docs/git-notes
Moses
  • 916
  • 8
  • 14
  • 1
    Hmmm, there is no such configuration for `notes.mergeStrategy` in my config. Here's my config output: `[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [remote "bitbucket"] url = https://xxx@bitbucket.org/xxx/xxx.git fetch = +refs/heads/*:refs/remotes/bitbucket/* [branch "master"] remote = bitbucket merge = refs/heads/master ` Shall I add it and use `notes.mergeStrategy` and set to `mine`? – SimonDowdles Nov 19 '15 at 14:12
  • 3
    This is such as common scenario, surely this does not warrant a complex solution. I would imagine more than 50% of people need to commit to dev branch from master to keep as many changes aligned as possible. – SimonDowdles Nov 19 '15 at 14:14
  • 2
    @SimonDowdles Did you find the solution to your issue? – kyw Jun 22 '19 at 02:36