Reputation: 915
I found some similar posts but not as per the exact requirement, so posting the question. (git branch -f master branchToMoveMasterTo does not help)
I have a branch created from master long back. I need to merge all the changes from this branch named branch_mb to master branch.
Here is the structure of current branches:
master
|---> brahcn_is
|---> branch_mb (30+ commits)
I need to merge all the changes from branch_mb, master should be exactly same as the branch_mb and commit history should be preserved.
Please suggest steps (merge, pull, fetch or any command is fine) that is reliable for production critical application.
Upvotes: 0
Views: 1916
Reputation: 3396
As far as I understand, you just want to merge a feature branch to master. This is common practice in a typical git workflow.
This should do:
# Fetch everything:
git fetch --all
# switch to master
git checkout master
# merge
git merge origin/branch_mb
# push the master
git push
If there is no commit to master after branch_mb, then it will be a fast forward.
Upvotes: 2
Reputation: 28599
You are saying that you want to overwrite origin/master
with branch_mb
?
Try this:
# This should Fail
git push origin branch_mb:master
# To truly overwrite master, force it
git push origin branch_mb:master --force
Upvotes: 1