series: git fundamentals
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:
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:
- git stores history as a graph
- git saves snapshots as trees
- the
.git/
folder is where the magic happens
Then we will configure authentication to github
so that we can pull down some code from an existing repository:
- how to: configure SSH keys to connect to Github
- how to: configure unique SSH keys per client
Next we will look at how git
branches and remotes work, what they are and what they are not:
- git branches are pointers into history
- git remotes are pointers to other repos
- most git commands operate locally
Finally we will build on that that to derive an understanding of how some common git
command-line tool works.
- git: staging and committing changes
- git: stashing and retreiving changes
- git: don't fear the rebase
- git: bisect explained
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: