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.

--

--

--

--

Quick-fire instructions to cherry-pick only certain files from a commit.

Git cherry-pick single file / files example.

Get the commit

git cherry-pick -n <commit>

Unstage everything

git reset HEAD

Stage the modifications you want to keep

git add <path>

Make the work tree match the index

# (do this from the top level of the repo)
git checkout .

Done!

--

--