Simple Guidance for Git in Visual Studio Code

Introduction

Visual Studio Code is the most popular IDE for all the frontend developer; for backend, some one says yes, though but not dominating like frontend pool.
Therefore, you easily get the a lot of how to setting for VS Code.
In this post, introduce the most essential setup for VS Code.

1. open VS Code by code . from CMD

Open VS Code, then Command + Shift + P. Select Shell Command: Install 'code' command in Path. (MAC)

VS Code


code-command

Then you can code . on CMD to open the current folder with VS Code.

CMD


code-command

2. Use VS Code as Git editor

Using Vim as the default editor for Git is always annoying because there is no sugar for editing text at all. For those who are stressed out from the same situation, VS Code can be the default Git editor.
Type the command below from your shell.

CMD

git config --global -e

You can edit the global setting of Git in the default editor.
Copy the text below to config space.

Vim

[core]
  editor = code --wait

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

You can use those Git command below with VS Code.

example

  • git rebase HEAD~3 -i : Allows to interactive rebase using VS Code
  • git commit : Allows to use VS Code for the commit message
  • git add -p : Followed by e for interactive add
  • git difftool <commit>^ <commit> : allows to use VS Code as diff editor for changes
Git Rebase panel in VS Code

code-command

add more in later …

Conclusion

There are more tips when you using VS Code.
However, those tips in this post help you to work in a lot better environment with VS Code & Git