Book Image

Gitlab Cookbook

By : Jeroen van Baarsen
Book Image

Gitlab Cookbook

By: Jeroen van Baarsen

Overview of this book

Table of Contents (16 chapters)
GitLab Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Squashing your commits


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.

How to do it…

In the following steps, we will squash some commits and push them to the server:

  1. Go to the super-git project in your terminal.

  2. Check out a new branch:

    $ git checkout -b squash-branch
    
  3. Let's create two commits in this new branch, which we can squash together:

    $ echo "1" >> README.md
    $ git add .
    $ git commit -a...