Merge dev into master and take all code from dev branch

We’ve been working with the dev branch in git for a long time now. All of our code is up to date on the dev branch. The master branch however is extremely out of date. We are looking to merge the dev branch back into the master branch to get it up to date.

However when we try to merge dev back into master, we get over 24,000+ conflicts. I know crazy! All the code in the master branch is out of date. Ideally we want to take everything in dev and overwrite what is in master.

Is there a way to merge dev into master and have it take all the latest code from dev and overwrite all conflicts to ensure dev files are taken? We don’t need to keep any code from the master branch seeing as it is all out of date. It would be too difficult to manually go through all conflicts when all we want is to take the dev branch code.

We will need to push this to the origin for all our team mates.

  • Bitbucket git push commits without cloning the repo
  • git subtree changes the package directory
  • How do I create a new git repository from a folder in an existing git repository?
  • Copy changes from an external untracked directory to separate Git working copy
  • Version control with MVFS
  • How can I merge my files when the folder structure has changed using Borland StarTeam?
  • Handling web.config differences across multiple machines when using version control
  • Extracting Source Code from an MS Access DB
  • 3 Solutions collect form web for “Merge dev into master and take all code from dev branch”

    @SnowMax’s answer is already good: with

    git checkout master
    git merge -X theirs dev

    However, depending on the state of your project, there might still be a problem with this. Namely, if some changes were made to the master that did not result in a conflict, but that you do with to throw away (as you stated “All the code in the master branch is out of date.”)

    In order to also throw these out, you can do (after the steps above)

    git checkout dev .
    git commit -m "undid useless changes to master"

    This will ensure that your entire git repo is checked out as dev
    If you don’t care about the commit history of your dev branch (you probably do care about it) only the last two lines suffice.

    Note that this also works if you still get merge conflicts in the first two lines…

    Simply use

    git checkout master
    git merge -X theirs dev

    You could simply force-push your development branch into your remote production.

    git push --force origin development:production
    Git Baby is a git and github fan, let's start git clone.