Git squash easy way
This small script mimics what GitHub's Squash portion does for their Squash and merge option on a Pull Request. It basically means you can easily squash all your commits into a single commit with this script without having to deal with finding out the first commit on your current branch that does not exist on the target branch.
- Download git-squash and place it in a path that is in
$PATH
sudo curl https://raw.githubusercontent.com/techgaun/git-squash/main/git-squash -o /usr/local/bin/git-squash && sudo chmod +x /usr/local/bin/git-squash
Assuming the local path ($HOME/.bin in this example) is in $PATH
:
curl https://raw.githubusercontent.com/techgaun/git-squash/main/git-squash -o "${HOME}"/.bin/git-squash && chmod u+x "${HOME}"/.bin/git-squash
- Make sure your current branch does not have merge conflicts with target branch
git merge main
git squash main