How to use Visual Studio Code as default editor for git?

Let’s learn the simple steps to set Visual Studio Code as the default editor in Git. This will help the developers to edit their code directly in VSCode instead of Notepad or other editors.

Git is a popular free version control software that was created initially to develop the Linux kernel. So that multiple developers can easily work and collaborate on the same project. Git allows developers to split project data into individual snippets. This makes it possible to work in a team and easily find the extensions or adjustments done to code by the individual team member.

The beauty of the Git version control system is it can track all the changes to files and allows multiple users to coordinate updates to those files. In addition, Git can also be used to manage file updates of any kind, is the version control standard for GitHub and other source code management systems, and is widely used in DevOps initiatives to implement CI/CD. Although Git is not a programming language, become an important part of software development.

Key Features- It can track updates made to the code base; can revert the previous version of code or file if something goes wrong; team gain insight into any changes made and identify the people who made them.

Once Git is installed, you can use it to manage your files and collaborate with others on software development projects. Some common Git commands for  users include:

  • git clone: This command is used to download a remote Git repository to your local computer.
  • git add: This command is used to add files to the staging area, where they will be tracked by Git.
  • git commit: This command is used to save changes to a Git repository.
  • git push: This command is used to upload local changes to a remote Git repository.
  • git pull: This command is used to download updates from a remote Git repository to your local computer.

For more information on using Git on Windows, you can consult the official Git documentation or seek help from the Git community.

What is Visual Code Editor?

Visual Studio Code source code editor developed by Microsoft; it is lightweight yet quite powerful. Users can run VSCode (call in short) on desktop PC and is available for Windows, macOS, and Linux. The development tool offers built-in support for JavaScript, TypeScript, and Node.js and has an extensive ecosystem of extensions for other programming languages (such as C++, C#, Java, Python, PHP and Go) and runtime environments (such as .NET and Unity).

Set Visual Studio Code as the default editor for Git

There are two ways to set VScode as a default file editor for Git on Windows one is GUI while installing it other is via the command.

Note: To set the VScode as a default editor for GIT, it must be already installed on your computer system.

Select the default editor while installing GIT on Windows

  • Download the GIT executable available for Windows on the official website
  • Double-click on the GIT executable file.
  • Follow the installation wizard by accepting the GNU license.
  • Soon GIT setup window will ask you to choose the default editor to use with GIT.
  • From the drop-down box select “Use Visual Studio Code as Git’s default editor“.
  • Click on the Next button and follow the further options to install the GIT on the Windows system.

Use Visual Studio Code as Gits default editor

Command to change Git editor to Vs code

Well, the command line method will work for Windows, Linux, and MAC. If you already have GIT installed and you want to change your default editor from Notepad, VIM, Nano, or any other to Visual Studio code then here are the steps to follow:

  • Open command terminal
  • Check Git is available using the command git --version
  • Once it is confirmed, use the given command to change the editor
  • git config --global core.editor "code --wait"
  • or
  • git config --global core.editor "code -w"
  • After changing the default GIt editor to Visual Studio code, let’s confirm it.
  • On your command terminal run:
  • git config --global -e
  • The above command will open the Gitconfig file in the VScode editor.

Command to change Git editor to Vs code

1 thought on “How to use Visual Studio Code as default editor for git?”

  1. git config –global core.editor “code –wait” did not work for me: VSC returned a “unable to open git-rebase-todo” error. What did the trick for me was:

    > git config –global core.editor “code –new-window –wait”

    This works the same as git config –global core.editor “code –wait”, with the difference that it opens a new instance of VSC.


Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.