Stage 3 of 6 · Lab, on the lab PC · about 20 minutes
Set up
Three one-time steps: a working git command, your identity attached to it, and a GitHub account. Everything here is typed in a terminal, so we start by opening one.
Open a terminal (just enough for today)
Git is driven by typed commands. On the lab PC (Windows), open PowerShell: Start menu, type powershell, Enter. On macOS it is Terminal; on Linux, any terminal. You type a command at the prompt, press Enter, and read the reply. Four commands cover today's navigation needs:
> cd Documents # change directory: go into the Documents folder
> mkdir iot-week1 # make a new folder
> cd iot-week1 # go into it
> ls # list what is here (works in PowerShell too)
This is a preview, not the terminal week
Week 2 teaches the Linux terminal properly, on the Raspberry Pi, with its own full page. Today you only need cd, mkdir, ls and the git commands; every one is shown where you use it. The Git commands themselves are identical on Windows, macOS, Linux and the Pi, which is precisely why the course teaches them first.
Check or install Git
The lab PCs should already have Git. Verify before installing anything:
> git --version
git version 2.43.0
Any version 2.x is fine for this course. If instead you get "git is not recognized" (Windows) or "command not found", install it:
Windows
Download Git for Windows and run the installer. The default choices are all fine; the one that matters is keeping "Git from the command line" enabled so PowerShell finds it. Close and reopen the terminal afterwards.
macOS / Linux
macOS: run git --version once; if missing, macOS offers to install the command-line tools. Linux: sudo apt install git on Debian/Ubuntu family systems, exactly the apt you will meet in Week 3. All platforms: git-scm.com/downloads.
Tell Git who you are
Every commit is stamped with a name and an email; that stamp is how contributions are traced to people, in this course and everywhere else. Set both once per machine (--global means "for my account on this computer, all repositories"):
> git config --global user.name "Your Name"
> git config --global user.email "you@example.com"
- Use your real name; graders and teammates read it in
git log. - Use the same email you will register on GitHub with, so GitHub links your commits to your profile. (If you prefer to keep your email private, GitHub offers a noreply address in Settings → Emails; you can switch to it later.)
- Quotes matter when there is a space in the value.
Verify anytime; the same command is also the first thing to check when commits come out mislabelled:
> git config --list
user.name=Your Name
user.email=you@example.com
init.defaultbranch=main
Shared lab PCs
The lab PC may remember the previous student's identity. Run git config --list at the start of every lab and re-set the two values if they are not yours; commits with a stranger's name on them cannot be re-attributed after the fact.
One useful default
Older Git versions named the first branch master; the modern convention, and GitHub's default, is main. Make your machine match so tutorials, this hub and your repositories all agree:
> git config --global init.defaultBranch main
Create your GitHub account
-
Sign up
At github.com/signup, with the same email you configured above. Enable two-factor authentication when prompted; GitHub requires it sooner or later, and sooner is painless.
-
Choose the username like it will outlive the course
It appears in every repository URL and, plausibly, on your CV.
m-tremblayormariotremblayages well;xX_darklord420_Xxdoes not. Changing later is possible but breaks links. -
Optional but worthwhile: the Student Developer Pack
As a CEGEP student you qualify for GitHub Education's Student Developer Pack: free private-repository features and a long list of developer tools. Apply with your Vanier email; approval takes a few days and nothing today depends on it.
That is the account. Connecting it to your terminal happens on the Share on GitHub page, at the moment you first push.
Checklist for this stage
Check yourself
Why does Git demand a name and email before anything else?
What does --global change about a git config command?
You sit down at a lab PC. What is the first Git command worth running, before any work?
git config --list. Shared machines remember the previous student's identity, and commits stamped with the wrong author cannot be relabelled after the fact.