I'm adding an answer because all the others were not succinct enough for my liking/did not fit my exact situation. I'm running a MacBook Air 2021 with an M1 chip
To make VS Code you default git editor in VS Code:
Step 1
Run the command git config --global core.editor "code --wait"
in your command line.
Step 2
If you try making a commit at this stage, you might get an error that looks like this:
"hint: Waiting for your editor to close the file... code -w: code: command not founderror: There was a problem with the editor 'code -w'".
This means you don't have the shell command "code" installed in VS Code. Use (command + shift + p) to open the command centre in VS Code. Search for "code" and select "Shell Command: Install ‘code’ command in PATH". This adds "code" to your path.
Step 3
While trying to install "code", you might get an error that looks like this:
"EACCES: permission denied, unlink '/usr/local/bin/code'".
I don't know what causes this but a simple uninstall and re-install resolves it. To uninstall, search "uninstall" in the VS Code command centre and select "Shell Command: Uninstall ‘code’ command in PATH"
Step 4
Run the command git config --global -e
to test what your new default editor is. Your config file should open in VS Code text editor
Sources: