When you're developing on your machine, chances are that you commit often and every time you commit, your commit message might become a little less explanatory. Commits such as
"Just testing" or
"lets see if this works" are common in this phase, which does not make for a nice-looking timeline. Squashing commits makes sure that you have a nice explanatory commit message and that you only have the relevant commits in the Git history.
Before you push all these commits upstream to your GitLab server, you might want to reorder these commits and pack them together in one commit that has a nice commit message and a great explanation of what you've done.
In the following steps, we will squash some commits and push them to the server:
Go to the
super-gitproject in your terminal.
Check out a new branch:
$ git checkout -b squash-branch
Let's create two commits in this new branch, which we can squash together:
$ echo "1" >> README.md $ git add . $ git commit -a...