Learnr

Learn Git

Track every change, branch without fear and collaborate on code.

or browse all courses.

Free to start. Built from a single prompt. No credit card.

Git is a distributed version control system, created by Linus Torvalds in 2005 to manage Linux kernel development. It records snapshots of your project called commits, lets you work on separate branches and merge them back, and gives every collaborator a full copy of the history. Hosting services like GitHub, GitLab and Bitbucket add pull requests and code review on top of Git, but Git itself runs locally from the command line. Beginners start with init, add, commit and log, then branches and remotes. Learnr builds a personalized Git course from one prompt with short, interactive lessons.

How to learn Git, step by step

  1. Install Git and configure your identity. Install Git, then set your name and email with git config --global user.name and user.email. Run git --version to confirm it works, and pick a default branch name like main.
  2. Learn the three areas with one practice repo. Run git init in a folder, edit a file and watch git status as you move changes from the working directory to the staging area with git add, and into history with git commit.
  3. Commit small and write useful messages. Make each commit one logical change with a short message saying what and why. Use git log --oneline and git diff to review your history, and add a .gitignore for build files and secrets.
  4. Practice branching and resolving conflicts. Create a branch with git switch -c, commit on it, then merge it back. Deliberately edit the same line on two branches to cause a conflict, open the file, resolve the markers and commit.
  5. Connect a remote and open a pull request. Create a repository on GitHub, add it with git remote add origin, then push and pull. Open a pull request from a branch, even in your own repo, to learn the review workflow teams use.
  6. Learn to undo safely. Use git restore to discard edits, git revert to undo a pushed commit, and git reset only on local history. Learn git reflog as your safety net, and review commands with short Learnr lessons.

What you'll learn

  • Explain the working directory, staging area and commit history
  • Make clean commits with clear messages and a useful .gitignore
  • Create, switch and merge branches and resolve merge conflicts
  • Push, pull and collaborate through a remote like GitHub
  • Undo mistakes safely with restore, revert and reset

What's inside your Git course

A sample path Learnr builds for Git. Your real course adapts to your goal and level.

  • 1. What version control is and how Git stores history
  • 2. The everyday loop: status, add, commit, log
  • 3. Branching and merging
  • 4. Remotes, push, pull and GitHub
  • 5. Pull requests and collaboration workflows
  • 6. Rebasing, stashing and undoing changes

How long does it take to learn Git?

The everyday commands for solo work take a few days to a week. Branching, merging and pull request collaboration take about 2 to 4 weeks of use on real projects. Rebasing and history editing come with a few months of regular team work.

What you need before you start

Basic comfort with a terminal helps, such as changing directories and listing files. Having a small project to track, even a folder of notes, makes practice meaningful.

Common mistakes to avoid

  • Committing secrets like API keys or passwords. Add them to .gitignore before the first commit, and rotate any key that was ever pushed.
  • Making one giant commit at the end of the day. Commit small, related changes so history is readable and easy to undo.
  • Force-pushing or rebasing a shared branch that others have pulled. Only rewrite history on branches you alone are using.

How Learnr builds your course

Type your topic

Tell Learnr you want to learn Git, or get as specific as you like.

Get a personalized course

Learnr instantly builds a full Git course tailored to your goal and skill level.

Learn and level up

Move through bite-sized lessons and interactive practice, earning XP and keeping your streak.

Git questions, answered

What is the difference between Git and GitHub?

Git is the version control tool that runs on your computer. GitHub is a hosting service for Git repositories that adds pull requests, issues, code review and collaboration features.

What is the difference between merge and rebase?

Merge combines branches with a merge commit and keeps history as it happened. Rebase replays your commits on top of another branch for a linear history, but rewrites those commits.

Do I need to use Git on the command line?

No, editors and desktop apps offer Git interfaces. Learning the command line first is worthwhile, though, because it shows what each action really does and works everywhere.

Explore more courses

More programming and tech courses

See all programming and tech courses

Ready to learn Git?

Start your free, personalized Git course in seconds. .