Check that you are at the correct branch
git checkout feature/MPX-2409-testHow many commits you want to squash together
git rebase -i HEAD~3Now vim file opens, press i to enter to insert mode. Change “pick” to “squash” for all the commits except the first one. This tells Git to combine these commits into one.
pick <commit1>
squash <commit2>
squash <commit3>When done, click esc to leave the insert mode, press :wq to save and leave
Another file opens in vim, press i to enter to insert mode. Add # in front of commit messages you don’t want, leave one without # (it will be the message of the new commit). You can also create a new message
[MPX-test] Message that will be used for the new commit
# [MPX-test] one message that won’t be used
# Some other text between
# [MPX-test] another message that won’t be used
# Some more text between commit messagesWhen done, click esc to leave the insert mode, press :wq to save and leave
Force push code to the repo when branch already exist
git push origin --force Push code to repo when branch doesn’t exist in origin yet
git push --set-upstream origin feature/MPX-2409-test