Rename/Edit/Squash commit(s)
If you want to git push --force on main, you may disable force protection on this branch in repo settings -> branches (e.g: https://gitlab.com/USER/REPO/-/settings/repository/branch_rules?branch=main)
Renaming the latest commit
Renaming any commit
For example: renaming HEAD~2 commit (HEAD is latest commit)
It will open text editor, You'll see something like this:

find the correct pick <commit hash> message and replace 'pick' to 'reword'
save and exit
(Squash) Replacing x last commits with 1 new single commit
Install Gitlens extension for VSCode: https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens
Press F1 and type
>GitLens: Git Rebase
then for example, type #<first-commit-hash>
It should open interactive rebase editor like this where you can squash commits:

When you're done, press "START REBASE" and close the git message files that it will open one by one
Last updated