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 initwhich creates a hidden directory called.git/
- The
initprocess fills.git/with a special file calledHEADthat contains the name of the branch or the commit we're on - If the contents of the
HEADfile is the name of a branch, then we can look in.git/refs/heads/<branchname>e.g..git/refs/heads/mainto figure out the specificcommitthe branch is on: e.g.ba012fe642b796af4e5735a7e6c83e4e90f9e62b - When we first start out,
HEADis likely themainbranch which maps to anil(non-existant) commit
- We can stage files to be committed to a checkpoint by using the command:
git addand then commit them usinggit commit -"message".