I have a very out of date master
branch in a git repository.
All of my work has been done in another branch.
What is the best way to merge the two?
I don't care about anything in master
, it is way out of date.
Using the -f flag, your previous master is completely overwritten with develop , including its history.
Usually git does not overwrite anything during merge.
If you are fine with losing the history of your master branch you just let master
point to the head of your current branch (your don't "overwrite" master
- the branch - per se):
git checkout yourotherbranch
git branch -D master
git checkout -b master
Of course if you have a remote clone, you'll then have to
git push -f origin master
Nota bene: this specifically applies to replacing the whole of your master
branch and throwing the old master
away as the title suggests.
Otherwise, you should be fine with git merge master --strategy=ours
.
Let's assume your work is in a branch called dev
:
git checkout dev
git merge --strategy=ours master
git checkout master
git merge dev
The merge option --strategy=ours
is meant to be used to supersede old development history of side branches (quote).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With