Git: replace commit history of Master with the history of feature branch

156 Views Asked by At

I'm new to interactive rebasing in Git so I made a branch where I could squash commits ( squash-branch ) just in case I ruined something. I didn't change any of the files on the branch, just the history. I merged the branch to master expecting that it would take the commit new commit history of the squash-branch.

How do I replace the commit history of master with squash-branch's history? To say it in a different mood, I want master to have squash-branch's history.

I've already tried two methods of force overwriting master with squash-history. The "ours strategy" and git branch -f master squash-branch.

Please notify if you need more details!

Thanks!

1

There are 1 best solutions below

0
On

git reset can do that:

git checkout master
git reset --soft squash-branch

Details in git-reset(1).

git reset [<mode>] [<commit>]

This form resets the current branch head to <commit>