Squashing commits
Squashing commits in Git involves combining multiple commits into a single commit. This is useful for cleaning up and simplifying the commit history.
Use git merge --squash to unify commits from a feature/topic branch into a single commit to be merged into your current branch.
When to use squashing:
- Before merging: Squash commits before merging a feature branch into the main branch to present the feature as a single, cohesive change.
- Cleaning up history: Reduce the number of commits in a branch by combining related changes into a single commit, making the history easier to follow.
- Improving commit messages: Combine multiple commit messages into a more informative and concise message, improving the overall clarity of the commit history.
- Preparing for review: Present a more coherent set of changes for review by squashing unrelated or minor commits into a single, meaningful commit.