Skip to content

Instantly share code, notes, and snippets.

@Shinrai
Last active April 29, 2019 23:00
Show Gist options
  • Save Shinrai/8518f9911acbf0e30b82cefac23cc4de to your computer and use it in GitHub Desktop.
Save Shinrai/8518f9911acbf0e30b82cefac23cc4de to your computer and use it in GitHub Desktop.
Reset Hotfix Branch After Pull Squash

Make sure to close all text editors or any programs accessing the files in the repo prior to running these commands.

Resetting a hotfix branch

git checkout master
git pull
git branch -f hotfix master
git checkout hotfix

Pushing the new commit history

git push origin +hotfix

The plus sign forces the remote branch to accept your rewritten history, otherwise you will end up with divergent branches NOTE: This will remove all commits in the hotfix branch that were used in a pull squash request

Make sure to close all text editors or any programs accessing the files in the repo prior to running these commands.

Resetting a feature branch

git checkout master
git pull
git branch -f feature master
git checkout feature

Pushing the new commit history

git push origin +feature

The plus sign forces the remote branch to accept your rewritten history, otherwise you will end up with divergent branches NOTE: This will remove all commits in the hotfix branch that were used in a pull squash request

For Easy Copy Paste to reset both branches

git checkout master
git pull
git branch -f hotfix master
git checkout hotfix
git push origin +hotfix

git checkout master
git pull
git branch -f feature master
git checkout feature
git push origin +feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment