GIT: Squashing commits

Sometimes we need to reduce commits count in our feature branch. To do that we can use rebase interactive mode. To do so, simply call something like that:

git rebase -i HEAD~13

Where 13 – count of commit you want to see.

Then you can choose which commits you want to squash into one. To do so, just change word

pick

to

s

in front of commits you want to squash. Note, that chosen commits will be squashed into previous commit.

Also in the same way you an change any commit messages. Commit messages is an important thing especially in large teams and project where commits history is an important thing. Here some useful rules  for that:

  • Must start with JIRA ticket
  • Must be between 20 and 72 characters
  • Must not end with a period
  • Must start with a capital letter
  • Must not be in the past tense (experimental)
  • Must not duplicate the message of other commits in the MR

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s