Last active
March 21, 2020 19:24
-
-
Save dfa1/8efa3ce530e02f719602e95ae4ef68f3 to your computer and use it in GitHub Desktop.
inattentively squash all commits of a topic branch (i.e. no need to open an editor as in rebase -i)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euo pipefail | |
target_branch=$1 | |
current_branch=$(git rev-parse --abbrev-ref head) | |
squash_branch=${current_branch}_work | |
git checkout -B ${squash_branch} ${target_branch} | |
git merge --squash ${current_branch} | |
git commit -am "squashed" | |
git checkout ${current_branch} | |
git reset --hard ${squash_branch} | |
git branch -D ${squash_branch} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment