Reputation: 2422
I have a project that we just rewrote which completely changed the file structure of the application, and upgraded many parts of it. I no longer care what's in the master branch; I want the PR I created to replace everything in master with what's in the version-2 branch. I'm just not sure what command to use.
I created the PR in GitHub, but it can't automatically merge for me (obviously) but running git merge dev
on the version-2 branch isn't working either, because I can't exactly tell if it's prioritizing the version-2 changes over anything in dev.
Hopefully this makes sense...which git command is the one I'm looking for? Again, when version-2 merges into master, I want version-2 to overwrite master in any potential merge conflict.
Upvotes: 0
Views: 1396
Reputation: 17455
You can create a "fake merge" by specifying a merge strategy ours
dedicated for your case:
git checkout version-2
git merge -s our master -m "This is a brand new version 2"
git update-ref -m "Promote master to version-2" master refs/heads/version-2
git checkout master
git branch -D version-2 # if nobody needs version-2 anymore
This way is slightly longer than renaming branches, but it allows to keep the whole history of your project. All the users of the master branch will receive the major change without any additional effort.
Upvotes: 1
Reputation: 80041
Assuming the two branches do not share history, you don't need them to share history (e.g. for other remotes to pull
from), and you'd like to promote dev
in place of master
, the easiest approach is merely to rename them:
git branch -m master old-version
git branch -m dev master
Note, this will not allow an existing repo elsewhere to git pull
their master
branch up to date. They could, however, git fetch
and then get checkout -b master --track origin/master
.
Upvotes: 0