How to completely replace all branch content with commits from another branch.
- your project has an
experimentalbranch for testing;
- you have some fixes in branch
- you want to overwrite content and history from
- you don't need to save any changes in
Then you can reset
experimental branch with the following commands:
git checkout experimental
git reset --hard fix-345
git push --force origin experimental
git checkout — checkout to the branch to be overwritten.
git reset --hard — get all changes from source branch to the target.
git push --force origin — force push your local changes for target branch