Configuring VS Code for Git Difference

We can use Visual Code editor for view the differences in the file changes. Here is how we can do it.

  1. First, we need to set the editor tool to vscode.

    > git config --global diff.tool vscode
    
  2. Next, tell git how to launch the vscode. We have to set code command to run as well for vscode. $LOCAL and $REMOTE are placeholders for old and new copies of file.

    > git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
    
  3. To be sure, let's check the default global configuration file.

    > git config --global -e
    
  4. Now we can run difftool command to see changes in working directory or staged area using following command.

    > git difftool
    > git difftool --staged