Clone branch into another with git

1 min read

How to completely replace all branch content with commits from another branch.

Let's say:

Then you can reset experimental branch with the following commands:

git checkout experimental git reset --hard fix-345 git push --force origin experimental

Steps description

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