Tutorial · Web development

Learn Git: the complete tutorial for beginners in 5 chapters

5 chapters · 39 min · Beginner · Git · verified on 2 September 2026

Quick answer

Git is a distributed version control system: it records the history of your files and lets several people work on the same project without overwriting each other. This five-chapter tutorial starts at installation and goes as far as choosing a branching model. Every command was run again with Git 2.55.0 before publication.

Git is a distributed version control system. It records the state of your files at every step of the work, lets you go back, and makes it possible for several people to work on the same project without overwriting each other. It is the basic tool of the developer’s trade: it is used for a hundred-line script as much as for the Linux kernel.

Git is not GitHub

This is the most common confusion when you start out. Git is a program that runs on your machine and keeps the history of your project in a hidden .git folder. It works with no internet connection and no account anywhere.

GitHub, GitLab and Bitbucket are hosts for Git repositories. They store a copy of your project on their servers, act as a meeting point for a team, and add their own tools around Git: issue tracking, code review, continuous integration. You can use Git your whole life without ever creating a GitHub account. The other way round makes no sense.

In this tutorial, Git is the tool you are learning. GitHub and GitLab are the services you use to share your work.

What you will be able to do at the end

  • Install Git and configure it properly first time, SSH key authentication included.
  • Create a repository on GitHub or GitLab and connect it to a folder on your machine, in both directions.
  • Record your work in readable steps, read the history, and undo a mistake without losing everything.
  • Work on a branch, merge it, and resolve a conflict by hand.
  • Choose a branching model that suits your team, between Gitflow and trunk-based development.

What you need

A terminal, and nothing else. This tutorial uses no graphical interface: no GitHub Desktop, no Git tab in your editor. Those tools are convenient once you understand what they are doing for you, and misleading before that. Every command works identically on Windows (in Git Bash), macOS and Linux.

No prior knowledge is expected, but being able to move around a terminal with cd and ls helps a lot.

A word about versions

Git is stable software that changes slowly: the commands in this tutorial have worked for years and will carry on working. Two points do move, and both are covered explicitly in the chapters concerned.

First, the git switch and git restore commands, introduced with Git 2.23 in 2019, which do a better job than git checkout at changing branch and undoing changes. They are no longer marked as experimental in the official documentation. This tutorial teaches them first, and gives the git checkout equivalent so that you can read other people’s code.

Then the name of the default branch. Contrary to a widespread belief, git init still creates a master branch in Git 2.55, not main. The change is announced for Git 3.0. The first chapter shows you how to settle that point once and for all.

The chapters

  1. Install and configure Git, installation per system, identity, default branch, and authentication by SSH key or token.
  2. Create a repository and get it locally, the two possible routes: clone an existing repository, or publish a folder you already have.
  3. The basic commandsstatus, add, commit, push, pull, the .gitignore file, and above all how to undo a blunder.
  4. Working as a team with branches, create a branch, merge it, resolve a conflict, and choose between merge and rebase.
  5. Gitflow or trunk-based, the two branching models, their commands, and the context in which each is justified.

The chapters follow on from one another: each picks the project up where the previous one left it. You can still go straight to the one that interests you, since the commands it needs are recalled there.

This tutorial is part of the Gekkode Web development track.

Start the tutorial

Newsletter

New tests, tutorials and projects, by e-mail.

Reproducible tests, versioned code, dated results. Never any spam.