If you use the git command line as your main go-to interface whether is how you learned or it’s your preferred method to interact with git, your user experience would only get better (hopefully) if you opt for an additional editor as your default client other than the command-line interface. In this article, we will look at how to properly set up your Visual Studio Code as your default git command-line editor along with an enhanced GitLense extension. If you are unhappy with the result, you can always go back.
Prerequisite, make sure you can run
in the command line.
Now follow the steps to update git config:
❯ git config --global core.editor "code --wait"
Next enter, this should bring up VScode and prompt the .gitconfig file for you to modify.
❯ git config --global -e
hint: Waiting for your editor to close the file...
Append the additional setting to your .gitconfig file
tool = default-difftool
cmd = code --wait --diff $LOCAL $REMOTE
Save and close the .gitconfig file this should allow the git command line to continue.
Now we can try some git interactive command such as git rebase <branch> -i
Before the change the interface looks like the above, you have to be comfortable in order to know all the git interactive flags. After the change, (if you have GitLense installed as VScode extensions) you are rebasing based on an entire GUI that’s provided by vscode and GitLense.
As a regular git user, this is very cool. It’s going to take some time to get used to the shortcuts that should be very similar to how git interactive runs in the command line.
If you want to go back, you can remove the code from the .gitconfig
git config --global -e
remove the [core] section or you can use –remove-section from the command line.