# Source Control (Git)

Git keeps a history of your project: every **commit** is a saved snapshot you can look back at,
and GitHub keeps a copy online. Open **Source Control** with the branch icon just above the
Assistant's sparkle, or **Ctrl+Shift+G**. A blue number on the icon counts the files you changed.

**Start**

- **Initialize Repository** turns the project folder into a Git repository. Studio also writes a
  `.gitignore`, so generated files (`.vi/`, `node_modules/`) stay out of the history.
- No Git on this PC? The view offers **Download Git** (about 50 MB, into Vi Studio's own folder;
  nothing else on your PC changes). On a Mac it shows the one command that installs it.

**Changes and commits**

- **Changes** lists every file you changed since the last commit: **M** changed, **A** added,
  **D** deleted, **U** new and not tracked yet. Click one to see a side-by-side **diff**: old on
  the left, new on the right.
- **+** stages a file (puts it in the next commit); **−** takes it back out. **Stage All** stages everything.
- Type a message that says what you did ("Add a delete button to tasks") and press **Commit**
  (or **Ctrl+Enter**). With nothing staged, Studio offers to commit every change.
- The first time, Studio asks for your name and email. They are written into each commit.
- **Discard** throws a change away and goes back to the last commit. Studio always asks first,
  and new files go to the Recycle Bin, not straight into oblivion.

**GitHub**

- **Publish to GitHub** opens github.com in your browser with a new repository already named
  after your project. Create it, copy its address, paste it into Studio, and Studio pushes your
  commits. The first push asks you to sign in to GitHub in a browser window.
- After that, **Sync** sends your new commits up and brings other people's down. The numbers
  next to it show how many commits are waiting each way.
- The branch name sits in the status bar. Click it to switch to another branch or create one.

**Recent Commits** at the bottom of the view lists the last 30 snapshots.
