Squashing By Merging With The –Squash Option
Git can combine the different changes into a single commit. The “–squash” option helps you to can merge multiple commits into a single commit.
Git combines all the changes into a single commit and applies it on top of the target branch.
Following are the steps to use “–squash”.
Step 1: Create and Switch to a new branch.
Create a branch that you want to merge into which is also called the target branch. After creating a branch change to that new branch by using the below command.
git checkout new_branch_name
Step 2: Merge the branch.
Know to merge the branch by using the “–squash” option including the git merge option. As shown below.
git merge --squash <Branch>
Step 3: Resolve and Commit the changes.
In between you may face some merge conflict issues which to be resolved manually. After resolving the issue commit the changes to the local repository where this commit will have a single message with all the commit history.
Step 4: Push the changes to the remote repository.
By using the git push command push the recent commit to the remote repository.
The commit history will be simplified by using the “–squash” option which makes it cleaner.
Contact Us