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.

  • Git deployment: removing files when push files removed
  • git add Signed-off-by line using format.signoff not working
  • how to fix GIT error: object file is empty?
  • key_load_public: No such file or directory even though file exists
  • Git Deployment Behind Load Balancer
  • cloning a remote branch results in cloning all remote branches…why?
  • 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.

  • Changing git repo's remote, missing some data?
  • Automatic prune with git fetch or pull
  • Do you feel comfortable merging code?
  • Notorious Git Error: remote rejected (failed to lock)
  • Remove old binary revisions from git and reduce size of git repository
  • Compare and Edit Branches in Git with a Mergetool
  • 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.