Reputation: 293
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.
Upvotes: 1
Views: 1345
Reputation: 1979
@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...
Upvotes: 5