Git & Source Control with VS Code
VS Code has Git built in — no plugin required. This lesson walks through staging, committing, branching, merging, and resolving conflicts all from within the editor.
1The Source Control View
Click the Git icon in the Activity Bar (Ctrl+Shift+G) to open Source Control. Changed files are listed under Changes. Stage individual files with the + icon, or stage all with Stage All. Type a commit message and press Ctrl+Enter to commit.
2Branching from VS Code
Click the branch name in the Status Bar to see a list of all branches. Type a new name to create one, or select an existing branch to check it out. You can also push the new branch to the remote directly from the same menu.
git checkout -b feature/login git merge main git push --set-upstream origin feature/login
3Viewing Diffs
Click any changed file in the Source Control view to open a side-by-side diff. Use the arrow buttons to move between changes. Stage individual hunks with the gutter icons — you don't have to stage entire files.
4Resolving Merge Conflicts
When a merge conflict occurs, VS Code highlights each conflict with inline labels: Accept Current Change, Accept Incoming Change, Accept Both, and Compare Changes. Use the 3-way merge editor (Resolve in Merge Editor) for complex conflicts.
5GitLens Extension
The GitLens extension supercharges built-in Git: inline blame annotations, file history, commit graph, code authorship, and compare-with-previous for any line. It's free and one of the most-installed extensions in the marketplace.