This guide provides a walkthrough of a basic git
workflow and attempts to describe what is happening under the hood as commands are run.
- We can create a new git repository using
git init
which creates a hidden directory called.git/
- The
init
process fills.git/
with a special file calledHEAD
that contains the name of the branch or the commit we're on - If the contents of the
HEAD
file is the name of a branch, then we can look in.git/refs/heads/<branchname>
e.g..git/refs/heads/main
to figure out the specificcommit
the branch is on: e.g.ba012fe642b796af4e5735a7e6c83e4e90f9e62b
- When we first start out,
HEAD
is likely themain
branch which maps to anil
(non-existant) commit
- We can stage files to be committed to a checkpoint by using the command:
git add
and then commit them usinggit commit -"message"
.