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
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