Skip to content

Instantly share code, notes, and snippets.

@bredmor
Created January 12, 2022 19:11
Show Gist options
  • Save bredmor/37cf51139cf59f22cc1412edc2729281 to your computer and use it in GitHub Desktop.
Save bredmor/37cf51139cf59f22cc1412edc2729281 to your computer and use it in GitHub Desktop.
Squash feature commits w/ no rebase
## Squashes all commits ahead of dev on current branch into one
## Before running, ensure all working files are comitted to feature branch
# Start on the current state of develop
git checkout develop
# Create a new temporary working branch
git checkout -b feature/TICKET-0000_temp
# Merge & Sqush your commits from the feature branch and commit them into the new temporary branch
git merge --squash feature/TICKET-0000
git commit -am "TICKET-0000 Ticket Description"
# (Optional) Move your unsquashed commits to a backup branch
git branch -m feature/TICKET-0000 feature/TICKET-0000_unsquashed
# Move your squashed commits onto the feature branch
git branch -m feature/TICKET-0000
git push origin refs/heads/feature/TICKET-0000:feature/TICKET-0000
# (Optional) Delete your local backup branch once you're done
git branch -D feature/TICKET-0000_unsquashed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment