Git basics

Git is a time machine for your files. It records small snapshots called commits, lets you experiment on branches, and helps you share work with a remote repository.

What you will learn

Important terms

Repository
The project folder and its Git history.
Working tree
The files you are currently editing.
Staging area
The changes selected for the next commit.
Commit
A saved checkpoint with a message.
Branch
A separate line of work that can later be merged.

Save one file

git status
git add index.html
git commit -m "Update the home page"
git log --oneline

First inspect the changes, then choose what belongs in the next snapshot with git add. Finally, save that selection with git commit.

Result: after the commit, git status no longer shows those changes as uncommitted.

Experiment on a branch

git switch -c feature/header
# edit files, then review and commit
git status
git add .
git commit -m "Add a header"
git switch main
git merge feature/header

Common points to remember

Back to the Git learning path