Reputation: 6119
I have some unwanted commits in master
branch, I've made a branch say, new_branch
from previous commit. Now new_branch
Looks better than master, I'd like to change new_branch
as my master
branch How can I do it?
Upvotes: 0
Views: 159
Reputation: 301147
You can do:
git branch -m master oldmaster
git branch -m new_branch master
Note that you will have to use force push if you have pushed elsewhere.
Upvotes: 1
Reputation: 363567
Locally, you can do
git checkout new_branch
git branch -D master
git checkout -b master
If master
has been pushed somewhere, you can now do
git push --force WHEREVER master
But watch out, since this will require everyone who pulled the previous master
to perform Git black magic to get the new master
.
If master
has been published, then it's better to just git revert
the bad commits.
Upvotes: 2
Reputation: 318508
Assuming you haven't published master
yet:
git reset --hard 'id of the last good commit in master'
to throw away the commits in mastergit merge --ff-only new_branch
to apply the commits from new_branch
to master.Upvotes: 0