Skip to content

Instantly share code, notes, and snippets.

@anton-dealmeida
Last active September 13, 2022 12:37
Show Gist options
  • Save anton-dealmeida/0e307520cc7d00d4be5e7b22737b23c8 to your computer and use it in GitHub Desktop.
Save anton-dealmeida/0e307520cc7d00d4be5e7b22737b23c8 to your computer and use it in GitHub Desktop.
A simply little snippet to squash your git commits into one commit for merging back to your source branch.
# Roll back all the commits done since branching from a develop branch but keep the changes.
# Note: Be careful to not loose your changes after running this command.
Write-Host "Rolling back commit tree to source branch."
git reset $(git merge-base develop $(git rev-parse --abbrev-ref HEAD))
Write-Host "Remember to commit all your changes and to run git push -f"
# Roll back all the commits done since branching from a develop branch but keep the changes.
# Note: Be careful to not loose your changes after running this command.
# This one is experimental
echo "Rolling back commit tree to source branch."
git reset $(git merge-base develop $(git rev-parse --abbrev-ref HEAD))
echo "Remember to commit all your changes and to run git push -f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment