Home / Blog / Post
Using Squash To Tidy Commits
Added on 10th March 2018 in Tutorial

I fequenty use different machines through the week rather than lug a laptop round with me. To keep my code uptodate I commit to and update the branch I am working on every time I am done writing a section, even if its not complete.

The convenience of this is that the code is always consistent, just pick up the next machine and pull the latest version. The negative for this is that branches look very messy in the log.

To clean this, we can squash commits into one when merging into master, like so:

git checkout master
git merge --squash branch-with-all-commits-in

The above merges in the code changes but does not make a commit or move to the head. From here we can commit all the changes as one commit.

git add *
git commit -m "Merged in Work For Issue X"

Hi there, I am christopher shaw, a software developer form South Yorkshire, England.

I love tinkering with all things tech, and opened this website as a web presence for myself and a place to keep my notes and snippets. Hopefully you will find something here to help

Christopher Shaw