Git & Command Line Tutorial · Command Line Basics · Lesson 1 of 20
Git & Command Line Introduction
What the command line is, why developers use it every day, and what Git does. A first look at both.
Why the command line?
The command line (also called the terminal or shell) lets you control your computer by typing commands instead of clicking. Developers use it every day because it's:
- Fast: one command can rename 500 files or search a whole project.
- Scriptable: anything you type can be saved and repeated.
- Universal: servers, containers and cloud machines usually have no graphical interface at all.
On macOS and Linux open Terminal; on Windows use Windows Terminal with WSL (a real Linux shell) or Git Bash. This tutorial uses bash; zsh (the macOS default) works the same for everything here.
Why Git?
Git is a version control system: it records every change to your project, lets you go back in time, work on features in parallel branches, and collaborate through services like GitHub and GitLab. Practically every software team uses it.
echo "Hello from the command line"
mkdir my-project && cd my-project
git init -b main --quiet
echo "# My Project" > README.md
git add README.md
git commit -m "First commit" --quiet
git log --oneline
Output
Hello from the command line 5e44428 First commit
Run this on your computer — see “Get Started” for setup.
Every example in this tutorial is a real bash script run in an empty folder, shown with its exact output.
Test yourself
What does Git do?
Compiles codeRecords the history of changes to your files so you can review, undo and collaborateHosts websitesFormats code
Show answer
Answer: Records the history of changes to your files so you can review, undo and collaborate