How to use VSCode as your default Git Interactive Command Line Editor

0

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

code

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

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

Save and close the .gitconfig file this should allow the git command line to continue.

2021 02 28 15 01 53 ● .gitconfig test Visual Studio Code 600x531 - How to use VSCode as your default Git Interactive Command Line Editor

Now we can try some git interactive command such as git rebase <branch> -i

2021 02 28 15 08 17 C  work test 600x461 - How to use VSCode as your default Git Interactive Command Line Editor
before change the git editor config

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.

2021 02 28 15 04 29 git rebase todo test Visual Studio Code 600x450 - How to use VSCode as your default Git Interactive Command Line Editor
after change the git editor config

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.

Was this article Helpful?

Thank you for the feedback!

LEAVE A REPLY

Please enter your comment!
Please enter your name here