VSCODE: I want to do "git merge --squash" from vscode

Viewed 9380

I have a master branch that is the production branch and so I create several other branches for fixes and defects. I make several changes in those branches and so I commit many times in those branches. As per the policy, I have to create a single commit for a defect in the master branch for a fix but when I merge my changes to master branch all the commits are also merged and so is reflected in the history.

I want to know if there is an option in VSCode to squash merge to the master branch from my defect branch, so I can just create a single commit in the master branch and push. I know how to do it in git bash but is there an alternative in VScode that I am not aware of?

1 Answers

The git graph extension has this feature - Usage example

The recording above assumes that the current checked-out branch is the branch you want to merge into (e.g. in the recording that branch is called master), and the branch that we want to merge is the branch that gets right-clicked (e.g. in the recording that branch is called fix_branch).

Since this is a squash merge, the fix_branch doesn't really get merged into master, a single squash-merge commit gets created on top of master. This new commit has just the previous commit marked as a parent, rather than the usual 2-parent commit that we get in regular non-squash merges.

Related