I sometimes find I'm working on a branch and I want to merge all changes from the branch into my master branch so that master is essential a clone of the branch I was just working with. Is there an easy way to update master so that all the changes from the branch are merged into the master. The behavior I am looking for is that master would become an exact clone of the branch. I usually merging individual conflicts one at a time into master, but is there an easier way to do this? Thanks for your time.
If you want to keep history, use the ours merge strategy:
git checkout branch
git merge -s ours master
If you don't care about the history of your master branch, reset it:
git checkout master
git reset --hard branch
(This will discard all your local changes and makes master's commit unreachable!)
If you don't have any commits in master that are not in your branch, you can fast-forward master to your branch:
git checkout branch
git merge master
# or `git merge --ff-only master` to only allow fast-forward
git reset --hard with the id of the commit you want to be your new master head should be your solution.
http://git-scm.com/2011/07/11/reset.html
EDIT : I'll flag it at duplicate : How to replace master branch in git, entirely, from another branch?
Look at the solution in the duplicate I mention. But depending on the desired result, the reset I suggested may be the solution.
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