Spin the Moose

series: git fundamentals

27 Nov 2021

Welcome traveller. Pour yourself a cup of tea and join me as we explore the git source control tool from first principles.

This post is part of a series on Git Fundamentals:

  1. series introduction (this post)
  2. git stores history as a graph

What is git?

git is

a distributed version control system designed to handle everything from small to very large projects with speed and efficiency. (from: https://git-scm.com)

git is a time machine for your terminal; it allows you to save snapshots of your code as you work and then travel backwards and forwards in time.

git is a magic wand; it allows you to rewrite history.

git is both very complicated and very simple.

This series will attempt to demystify git and provide a practical foundation for using it confidently and effectively.

Who is this series for?

Many people learn git by example and learn just enough to contribute to open-source or internal projects but never really understand how git works.

This series is for anyone who:

  • finds git intimidating;
  • finds yourself confused while working with git tools;
  • learned git by using it but wants to understand more about how it works;

Our roadmap

We will start with some theory, looking at how git stores snapshots and represents history:

  1. git stores history as a graph
  2. git stores snapshots as trees
  3. .git/ is where the magic happens

Then we will look at how git branches and remotes work, what they are and what they are not:

  1. git branches are pointers into history
  2. git remotes are pointers to other repos

Finally we will build on that that to derive an understanding of how the git command-line tool works.

  1. git: staging and committing changes
  2. git: stashing and retreiving changes
  3. git: don't fear the rebase

What about GUI tools?

I have worked with a variety of graphical git tools that allow you to work with git through a Graphical User Interface (GUI), including:

  • VSCode plugins
  • on-board context menus in Visual Studio and IntelliJ
  • Github Desktop
  • SourceTree
  • Git-Fork
  • GitKraken

All of these graphical tools are built as wrappers around the core functionlity exposed through the git command line.

While graphical tools can be useful abstractions I strongly recommend first learning how git works at the command-line level.

Once you understand how git works under the hood every GUI tool will make sense.

A special note about gitk

gitk is a fast, simple tool for visualizing and navigating the history stored in a local git repository, and is the one exception I have to my “learn the CLI first” policy.

gitk comes bundled with the installation of git on windows systems and is available as a separate package when installing git through package managers like yum or brew.

While most git GUIs try to simplify the way git works, gitk’s provides a simple window into your local git repo without any distracting bells and whistles.

Plus it is lightning fast and rock-solid stable just like git itself.

Okay, let’s get started!

This index will appear on all the posts in this series:

This post is part of a series on Git Fundamentals:

  1. series introduction (this post)
  2. git stores history as a graph
david@spinthemoose.com
github//davidalpert
twitter//davidalpert
© 2021 David Alpert
This site is hosted at Github Pages and created with Jekyll.