World map

 

BM: Baca dalam Bahasa Melayu

World 0: Start Here

Git inside VS Code

You will learn: where Git lives in VS Code, and what each part does.

The problem

git status: index.html is modified and style.css is untracked. Both are red. Terminal output: $ git status On branch main Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) modified: index.html Untracked files: (use "git add <file>..." to include in what will be committed) style.css no changes added to commit (use "git add" and/or "git commit -a")

This is git status in a terminal. That’s a lot of words. Is there an easier way to see it?

Try it

This is VS Code, a free code editor. Tap each glowing dot.

Tap the glowing dots to explore.

0 of 7 explored

Watch

git add style.css, then git commit with the message Add styles. Git makes one new commit. Terminal output: $ git add style.css $ git commit -m "Add styles" [main 0a7422c] Add styles 1 file changed, 1 insertion(+) create mode 100644 style.css

The buttons run the same Git commands. Clicking + runs git add. Clicking Commit runs git commit.

Predict

You click + next to style.css. Where does it go?

Pick one answer.

Check

In the diff, one line is green. What does green mean?

Pick one answer.

Watch

git log --oneline in the VS Code terminal lists two commits. Terminal output: $ git log --oneline 3a12797 (HEAD -> main) Add home page 6d3a9b1 Add README

VS Code has a terminal inside, too. Open the Terminal menu, then New Terminal. Every command from this course works there.

You did it!

You can now find Git’s buttons in VS Code.

Go deeper (optional)

Hover over a file in Changes to see more buttons. The curved arrow throws away your changes, so use it with care. Install VS Code from code.visualstudio.com. It works on Windows, macOS and Linux.