Git and GitHub
By the end of this step you have git installed, a GitHub account, and your terminal signed in to it.
You'll use git properly in Module 0's last step. Here you only install it and sign in.
Quick check: run these two. If both print a version, skip to part 2.
git --versiongh --version1. Install git
On Windows
- Go to git-scm.com/downloads/win and click the download for 64-bit Git for Windows Setup.
- Open the installer. You can click Next on almost every screen; the defaults are fine. Two screens worth changing:
- "Choosing the default editor used by Git": pick Use Visual Studio Code as Git's default editor.
- "Adjusting the name of the initial branch": pick Override the default branch name and leave it as
main.
- Click Install, then Finish.
- Close all terminals and open a new one.
On macOS / Linux
- In the terminal, run:
git --version- If a popup asks to install the command line developer tools, click Install and wait (a few minutes). That installs git.
- When it finishes, run
git --versionagain.
2. Create a GitHub account
- Go to github.com/signup.
- Enter your email, a password and a username. Pick a username you're happy for employers to see: it appears on everything you share.
- Confirm your email address with the code GitHub sends you.
Already have one? Use it.
3. Tell git who you are
Every version you save is stamped with your name and email. Set them once (use your own name, and the email from your GitHub account):
git config --global user.name "Your Name"git config --global user.email "you@example.com"These commands print nothing when they work. That's normal: in the terminal, silence usually means success.
4. Install the GitHub CLI and sign in
The GitHub CLI (gh) lets you do GitHub things from the terminal: create repos, open pull requests. It also signs git in to your account, so you never type a password for it.
- Go to cli.github.com and click Download for Windows (or Download for Mac).
- Run the installer with the default options.
- Close all terminals and open a new one.
- Run:
gh auth loginIt asks a few questions. Use the arrow keys to choose and Enter to confirm:
| It asks | Choose |
|---|---|
| Where do you use GitHub? | GitHub.com |
| What is your preferred protocol for Git operations? | HTTPS |
| Authenticate Git with your GitHub credentials? | Yes |
| How would you like to authenticate GitHub CLI? | Login with a web browser |
- It shows a one-time code like
ABCD-1234. Press Enter: your browser opens GitHub. - Paste the code into the page, click Continue, then Authorize github.
- Go back to the terminal. It says you're logged in.
Now check:
gh auth statusIf it didn’t work
"gh is not recognized" / "command not found: gh". Close every terminal, including the one in VS Code, and open a new one. New programs only appear in new terminals.
The browser didn't open. Copy the address the terminal prints (https://github.com/login/device) into your browser yourself, then paste the code.
"Author identity unknown" later on. You skipped part 3. Run the two git config commands.