Skip to content

Instantly share code, notes, and snippets.

@kriscooke
Last active October 18, 2019 00:19
Show Gist options
  • Save kriscooke/d806013ec8494fd7672c23315c980fac to your computer and use it in GitHub Desktop.
Save kriscooke/d806013ec8494fd7672c23315c980fac to your computer and use it in GitHub Desktop.
How to use VSCode as your default Git message editor

How to use VSCode as your default Git message editor

1. Make it possible to open VSCode from the terminal:

Use Cmd + Shift + P to open the command menu Type and select: Shell Command: Install 'code' command in PATH

This allows you to open VS Code from your terminal. ex: In your terminal, type code . from your terminal to open the current directory in VSCode.

2. Change your .gitconfig file in your home folder (use Cmd + Shift + . in Finder to see hidden dotfiles) to use the above VSCode command (instead of vim) for typing commit messages etc:

Open ~/.gitconfig in your editor and add the following. You may or may not already have any config options here - you don't need to erase any existing ones, just make sure that at minimum the following fields are present: (the --wait flag means that the commit or other git process will be completed once you save & close the editor tab, instead of leaving the process hanging).

[user]
	name = Santa Claus
	email = [email protected]
[commit]

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

Extra: Obscure your personal email address from public view on public repo commits

Notice under the [user] config above, the email is set to [GITHUB_NAME]@users.noreply.github.com. This is a handy feature offered by Github. Git forces you to set an email, but then of course this email is visible to anyone on the Internet for all of your public repository commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment