KevsRobots Learning Platform
By , Minute
Git may already be on your computer, especially on a Mac, Linux or a Raspberry Pi. Open a terminal and type:
git --version
If you see something like this, you’re ready to skip ahead to Telling Git who you are:
git version 2.47.1
Any version from 2.28 onwards is fine for this course. If you get command not found, install it using the steps for your system below.
Where’s the terminal?
- Windows: after installing Git, open Git Bash from the Start menu. You can also use PowerShell or the terminal in VS Code.
- macOS: press
Cmd + Space, type Terminal and press Enter.- Raspberry Pi and Linux: open Terminal from the menu, or press
Ctrl + Alt + T.
git --version.Git for Windows also installs Git Credential Manager, which will handle signing in to GitHub for you later.
You can also install it from PowerShell with winget install --id Git.Git -e.
The simplest way is to type git --version in Terminal. If Git isn’t installed, macOS offers to install the Command Line Developer Tools, which include Git. Click Install and wait a few minutes.
If you use Homebrew, you can get a newer version with:
brew install git
Git is usually installed on Raspberry Pi OS already. If not:
sudo apt update
sudo apt install git
On Fedora use sudo dnf install git.
Every commit records the name and email of the person who made it, so Git needs to know yours. Run these two commands, using your own details:
git config --global user.name "Ada Lovelace"
git config --global user.email "[email protected]"
--global means “for every repository on this computer”, so you only have to do this once per machine. If you plan to use GitHub, use the same email address as your GitHub account so your commits are linked to your profile.
Keep your email private
Commits on GitHub are public, and so is the email in them. GitHub gives every account a private
noreplyaddress you can use instead. Find it under Settings > Emails on GitHub.
Call the first branch main. Newer versions of Git and GitHub both use main as the name of the first branch. Older versions of Git used master. Set it once so everything matches:
git config --global init.defaultBranch main
Pick an editor you know. Some Git commands open a text editor for you to write a message. If you don’t set one, you might land in Vim, which is famously hard to quit (the answer is to type :q! and press Enter). To use VS Code instead:
git config --global core.editor "code --wait"
Or for the simple terminal editor nano, which is great on a Raspberry Pi:
git config --global core.editor "nano"
To see everything you’ve set:
git config --global --list
user.name=Ada Lovelace
[email protected]
init.defaultbranch=main
core.editor=nano
git config --global --list and check it’s all correct.git help commit. Git has a full manual for every command, and you can open it any time with git help <command>. Press q to quit the manual.git: command not found (or 'git' is not recognized on Windows)Why: Your terminal only looks for programs in certain folders, and only checks for new ones when it starts.
git config --global user... commands again with the right details.Why: Git stamps each new commit with whatever is in your settings at the time. Changing them won’t alter old commits, only new ones.
Esc, type :q! and press Enter. Then set core.editor as shown above.Quick quiz 1 of 2
What does --global mean in git config --global user.name "Ada"?
Quick quiz 2 of 2
Why set init.defaultBranch to main?
master. Setting it to main avoids mismatches when you push to GitHub.
You can use the arrows ← → on your keyboard to navigate between lessons.
Comments