Let's say you are done with an new feature. Now you want to merge your feature into the master or develop branch. To keep a good overview within your Git log, you want just 1 Git commit within your log. You do not want all Git commits which you have made during the development in your Git log. Because this would pollute the Git log.
The following way firstly checks out your master branch. Then you are "squashing" all your Git commits to 1 commit. Afterwards you specify the 1 commit which holds your changes.
$ git checkout master
$ git merge --squash yourBranch
$ git commit -m "[#MY-TICKET-ID] Squashed commits."