Skip to content

Instantly share code, notes, and snippets.

@ahamed
Created January 28, 2021 10:53
Show Gist options
  • Select an option

  • Save ahamed/9020fce5b70b40214d1f5fa89a637ef6 to your computer and use it in GitHub Desktop.

Select an option

Save ahamed/9020fce5b70b40214d1f5fa89a637ef6 to your computer and use it in GitHub Desktop.
Force push a branch to another branch without keeping the history or matches.
# Checkout to the reseting branch
#e.g. `git checkout master`
git checkout old_branch
# reset hard by the new branch's contents
# e.g. `git reset --hard origin/v2.0.0`
git reset --hard new_branch
# force push the contents to the origin
# e.g. `git push origin master --force`
git push origin old_branch --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment