Command Line Git

Everything You Need to Know to Get Started

Master Git from command line.

Learn the skills necessary to work in companies like:

  • Spotify
  • Dice
  • Mojang Studios
  • Microsoft
Get It Now

Small startups and big companies use Git in their workflows to:

  • backup the code
  • deploy projects
  • find and fix bugs
  • collaborate on the same project as a team
  • safely experiment with new features

The problem is – Git can be very confusing.

  • Git has many commands each with it’s own set of options.
    • Commands can behave differently depending on their options.
  • The command line interface has no visual guidance.
    • You have to use your imagination to understand what is going on.
  • The concepts used by Git: diff, staging, commits, branches, remotes, etc.
    • It is not always clear what they mean and how they work.

If you get stuck with Git and search for help – you’ll find two kinds of resources:

  • Specific recipes that you have to follow blindly
  • Reference manuals full of complex terminology and technical details

This Book is Different

It is a guide that will help you understand how Git works.

It is designed to give you the necessary knowledge to get started without overwhelming you with too much information.

Key Features

Mental Models – analogies and visualizations to help you understand how Git works.

Illustrations – the book has illustrations that will help you understand the concepts better and make them more memorable.

Exercises – each chapter has exercises that will help you understand and remember the concepts better. They will also help you develop the muscle memory for the commands.

Example Repositories – most exercises have example repositories that you can use to experiment with Git. This will be very useful even after you finish the book. You will be able to use them as testing grounds if you got stuck with a problem in your project.

How This Book Helps

First it goes over a typical workflow explaining what happens at each step. This is needed so that you have the place to stick the new knowledge to.

Then it goes over the most important commands and concepts.

To help you understand and remember the concepts, the book uses analogies and visualizations.

In the end of each chapter there are exercises that use example repositories.

These exercises will help you understand and remember the concepts better.

The example repositories that come with the exersizes also serve as laboratories where you can experiment with Git. This will be very useful even after you finish the book. You will be able to use them as testing grounds if you got stuck with a problem in your project.

Hi, My Name is Maksim

I’m a software developer. I worked on many great projects:

  • admin interfaces for Spotify
  • web services around Minecraft and Minecraft Dungeons
  • in-game UI for Battlefield V

I wrote this book to share the experience I gained from using Git on various projects.

My goal with this book is to save you time and effort in learning Git, enabling you to become efficient with it right from the start.


  • Q: What happens after I buy?
    • A: After the checkout you’ll be redirected to a page with download link for the zip archive containing the book and the example repositories. We’ll also send an email with the download link to your provided email address, ensuring you have easy access to your purchased content at any time
  • Q: What if I don’t like the book?
    • If you’re unhappy with the book for any reason and you bought the book on this website (, just reach out to us within 30 days and we’ll give you a full refund. There’s no risk.
    • If you bought the book in any other store where it is available – then it will depend on return policy of the given store.

Download Free Preview

Leave your email to download the first chapter for free.

I will occasionally send updates when new books and courses become available.

Get the Book

Command Line Git

Everything You Need to Know to Get Started

  • PDF, EPUB and MOBI formats
  • Over 150 pages
  • 45 exercises
  • 38 example repositories
Get It Now for $19.99

Get It In Your Favorite Store

Table of Contents

  1. Introduction
    • Why Learn Git?
    • Why Use the Command Line?
    • Prerequisites
    • What You’ll Learn
  2. How Git Works – Building a Mental Model
    • What is Version Control?
    • What is Distributed Version Control?
    • How Does Git Work?
    • Git Workflow
  3. Installing and Using Git on Windows
    • Installing Git Using the Official Installer
    • PowerShell Primer
  4. Installing Git on Mac OS
  5. Installing Git on Linux
  6. Mac OS and Linux Command Line Primer
    • How to Open the Command Line
    • How to Use the Command Line
  7. Configuring Git
    • Configuration Levels
    • Configuring Git Using Text Files
    • Complete List of Available Settings
    • Using the Config Command
    • Setting Configuration Options
    • Removing Configuration Settings
    • Viewing Configuration Settings
    • Exercises
  8. Creating a Repository
    • Before You Start
    • How to Clone a Repository
    • How to Initialize a Repository in an Existing Folder
    • What is Inside the .git Folder
    • Exercises
  9. Checking the Status of a Repository
    • How to Use the Status Command
    • Short Status
    • Exercises
  10. Selecting Changes to Commit – Staging
    • How to Stage Changes
    • Staging Multiple Files
    • Viewing Staged Changes
    • Removing Files From the Staging Area
    • Staging Individual Changes
    • Exercises
  11. Committing Changes
    • Merge Commits
    • How to Commit Changes
    • How to Overwrite the Last Commit
    • Exercises
  12. Understanding .gitignore
    • How to Ignore Files
    • Glob Patterns
    • Generate a .gitignore File for Your Project
    • Exercises
  13. Viewing the Commit History
    • How to View the Commit History
    • How to View the Commit History in One Line
    • How to View the Commit History in a Graph
    • Exercises
  14. Switching Between Commits
    • What Does It Mean to Switch Between Commits?
    • How to Switch to a Particular Commit
    • How to Switch Relative to the Current Commit
    • How to Switch Back
    • Exercises
  15. Understanding HEAD
    • When the HEAD is Detached
    • What Happens When You Commit in the Detached HEAD State
    • How to Find Dangling Commits
    • How to Reattach the Dangling Commit
    • How to Fix the Detached HEAD
    • Exercises
  16. Restoring the Working Directory
    • Discarding the Untracked Files
    • Discarding the Tracked Files
    • Discarding the Staged Files
    • Exercises
  17. Undoing Changes
    • Reverting the Commit
    • Resetting Changes
    • Exercises
  18. Using branches
    • How Does Git Store Branches
    • Creating New Branches
    • Switching Branches
    • Listing Branches
    • Deleting Branches
    • Merging Branches
    • Exercises
  19. Resolving Merge Conflicts
    • How Conflicts Happen
    • How to Avoid Conflicts
    • How to Resolve Conflicts
    • Exercises
  20. Stashing changes
    • What is a Stash?
    • Put Aside Changes
    • View Stashes
    • Using Named Stashes
    • Preview Stash Contents
    • Apply Stashes
    • Drop stash
    • Exercises
  21. Using Remotes
    • What is a Remote
    • Adding a Remote
    • Adding GitHub as a Remote Repository
    • Listing Remotes
    • Pushing to a Remote Repository
    • Pulling or Fetching from a Remote Repository
    • Renaming Remotes
    • Removing Remotes
    • Exercises
  22. Afterword
  23. Appendix
    • Answers to Exercises