Mastodon

Setting Visual Studio Code As Your Git Editor

My last post seemed to go down quite well, so I’m going to try a few mini-posts with a ‘tips-and-tricks’ theme. This works well for me as I’d started making some notes about productivity tips I use as part of my prep for an internal no-prep presentation ;-)

This one is a really small tip that is covered in the Visual Studio Code docs, but lots of people using Visual Studio Code seem to have missed it so I’m going to mention it here: you can set Visual Studio Code to be your git editor. To do this run:

git config --global core.editor "code --wait"

As the docs point out, once you have done this you can run git config --global --edit to add the following sections to your git config:

[diff]
    tool = default-difftool
[difftool "default-difftool"]
    cmd = code --wait --diff $LOCAL $REMOTE

Once you’ve done this you will now use Visual Studio Code as the editor whenever git prompts you for commit messages, actions to take on rebase, etc.