Git rebase in Visual Studio Code

I don't think Visual Studio Code has Git rebase functionality built-in. If you want to do your rebasing in Visual Studio Code instead with the git command-line tool or with a Git GUI, you can install the GitLens extension for VS Code.

GitLens’s README indicates that GitLens supports rebasing. It says that when viewing branches, the context menu for each branch includes these commands:

  • Rebase (Interactive) Branch (via Terminal)
  • Rebase (Interactive) Branch to Remote (via Terminal)

And when viewing the commits in one branch, the context menu for each commit includes this command:

  • Rebase to Commit (via Terminal) (when available)

I just tried, it works!! enter image description here

PS: I try to find the approach to setting the default "Sync" action with --rebase paramter. I find the PR of Added config option to sync+Rebase from statusbar, but it haven't landed.

Finally find the solution, git config --global pull.rebase true and it works!!


You could run the command directly from your terminal with: git rebase branch or git rebase -i branch

You will have to configure your gitconfig to use vscode for the interactive rebase.

Something like:

[core]
  editor = code --wait

Or by setting your envar to GIT_EDITOR=code\ --wait

As soon as you want to do something a bit out of the ordinary, using the command line yield better results.