Phase 1 15 min windows macos linux

Install and Configure Git

Version control that tracks your code and connects to GitHub

What Git Does

Git is version control software. It tracks every change you make to your code, lets you undo mistakes, and makes it possible to submit your work through GitHub. Without Git, you’d be emailing ZIP files or losing work when your laptop crashes. Every professional developer uses it daily.

Check If You Already Have It

git --version

If you see git version 2.x.x (any recent 2.x version is fine), skip to Configure Git. If you get “command not found,” install it below.

Install Git

Windows 1. Download Git for Windows from [https://git-scm.com/download/win](https://git-scm.com/download/win). 2. Run the installer. 3. **Use the default options for everything** except: - "Adjusting your PATH" — select **"Git from the command line and also from 3rd-party software"** (this is usually the default). - "Configuring the line ending conversions" — select **"Checkout Windows-style, commit Unix-style line endings"** (the default). 4. Finish the installer. 5. **Close and reopen** any terminal windows. Git for Windows includes Git Bash, a Unix-like terminal. You can use it, but PowerShell or the VS Code terminal works fine too.
macOS **Option A: Xcode Command Line Tools (easiest)** ```bash xcode-select --install ``` A popup will appear. Click "Install" and wait. This installs Git along with other developer tools. **Option B: Homebrew** ```bash brew install git ```
Linux (Ubuntu/Debian) ```bash sudo apt update sudo apt install -y git ``` For Fedora: `sudo dnf install git`

Verify Installation

git --version

You should see something like git version 2.43.0. Any 2.x version released in the last few years is fine.

Configure Git

Git attaches your name and email to every commit. Set these now. Use the same email you’ll use for your GitHub account.

git config --global user.name "Your Actual Name"
git config --global user.email "your.email@eagles.ewu.edu"

Set the default branch name to main (instead of the old default master):

git config --global init.defaultBranch main

Verify your config:

git config --global --list

You should see your name, email, and init.defaultbranch=main in the output.

The 6 Commands You’ll Use Most

You don’t need to memorize these now. You’ll learn them through practice. This is just a reference.

Command What It Does
git clone <url> Copy a remote repository to your computer
git status Show what’s changed since your last commit
git add <file> Stage a file for the next commit
git commit -m "message" Save staged changes with a description
git push Upload your commits to GitHub
git pull Download new commits from GitHub

A typical workflow: status to see what changed, add to stage files, commit to save, push to upload. That’s it for 90% of this course.

Common Errors

“git: command not found”

Git isn’t installed or isn’t on your PATH. On Windows, make sure you closed and reopened your terminal after installing. On macOS, run xcode-select --install if you haven’t.

“Author identity unknown … Please tell me who you are”

You skipped the git config step above. Run the git config --global user.name and git config --global user.email commands.

“fatal: not a git repository”

You’re running a Git command in a folder that isn’t a Git repo. Use cd to navigate into your project folder first. Run git status to check if you’re in the right place.

Line ending warnings on Windows

warning: LF will be replaced by CRLF

This is normal on Windows. Git is converting line endings automatically. You can safely ignore this warning.

Next Step

Git is installed and configured. Next, install VS Code so you have a proper editor to write Java in.