33
Using VS Code to git rebase
Git rebase is a powerful, albeit confusing tool. I primarily use rebase to squash my commits before I PR my branch into
main
. This tutorial will show you how to use VS Code to visually do this process.You will need to install this VS Code extension: https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens
You will also need to enable "force push":
In settings, search for "git allow force push" and check the box

Optional but recommended: set VS Code as your git editor:
git config --global core.editor "code --wait"
main
) is up to date.git rebase -i main
, where main
is the branch you are rebasing ontosquash
every commit, and reword
the last one into a good commit message.Start Rebase
button.Pull, Push
menu, choose Push (Force)
. Use this with caution, especially when working with other developers, as force push is destructive.And we are done! A very easy way to rebase and squash all your commits using VS Code.