git squash branch code example
Example: git squash branch
git checkout yourBranch
git reset --soft HEAD~$(git rev-list --count HEAD ^master)
git add -A
git commit -m "one commit on yourBranch"
git rev-list --count HEAD ^master counts the commits since you made your feature branch from the master, f.ex. 20.
git reset --soft HEAD~20 will make a soft reset of the last 20 commits. This leaves your changes in the files, but removes the commits.
alias gisquash='git reset --soft HEAD~$(git rev-list --count HEAD ^master)'
git push --force