Skip to content

Instantly share code, notes, and snippets.

@brianbirir
Last active September 4, 2023 10:15
Show Gist options
  • Save brianbirir/ab74876f050c8b222481357cb087b994 to your computer and use it in GitHub Desktop.
Save brianbirir/ab74876f050c8b222481357cb087b994 to your computer and use it in GitHub Desktop.
Git Squash Rebase
#!/bin/sh
# Squash rebase all the commits in your working/feat. branch in one line against a base branch:
# git cherry -v base_branch | wc -l | awk '{print $1} gets the number of commits from the start of your branch
git rebase -i HEAD~$(git cherry -v base_branch | wc -l | awk '{print $1}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment