Git Squash without rebase

--

Quick steps to squash commits without having to rebase.

If you’re working on a feature branch for example; this method will let you squash all commits into one as you merge them into another branch.

  1. Merge master into the feature branch
// from branch my-feature (assume has 10 new commits)
git merge master
// fix conflicts & commit

2. Squash my-feature` into master`

git checkout master
git merge --squash my-feature

3. Commit changes as one.

git commit -m "Adds my-feature to master"

4. Result

All 11 commits appear as 1 in the master branch history.

--

--