Skip to content

Instantly share code, notes, and snippets.

@domgetter
Created December 13, 2015 05:59
Show Gist options
  • Save domgetter/ae05c29f9833ddfbb32e to your computer and use it in GitHub Desktop.
Save domgetter/ae05c29f9833ddfbb32e to your computer and use it in GitHub Desktop.
Git is Easy
Git is three things
Objects
Refs
commands - CRUD for objects and refs
Shadow Directory (aka index or staging area aka what the next commit will look like)
untracked files (files which are not in any tree object in HEAD or the shadow directory. basically, files that git doesnt know about by name)
Objects
Blobs
Trees
Commits
Tags
Refs
Branches (pointers to commits)
Remotes (aka peers)
HEAD (pointer to branch (or a commit in "detached HEAD" state))
commands can be understood based on how the objects and refs are created, read, updated, or deleted
add - CREATE blob objects for each file I added
UPDATE shadow directory to account for added file(s)
commit - CREATE tree object out of the shadow directory
CREATE commit object that points to the previous commit (found in HEAD)
points to the tree object that was just made out of the shadow directory
fills in metadata about who made the commit and when
fills in a message to describe the commit
UPDATES the currently checked out branch (probably master) to point to commit it just made
push - copies objects to a remote peer on the branch specified
pull - copies objects from a remote peer on the branch specified
log - READ the commit that HEAD points to through the branch HEAD refers to and to that commit's parents
ls-files --stage - READ shadow directory and print to the console
checkout - UPDATES HEAD
UPDATES working directory to look like the tree that HEAD refers to (ignores untracked files)
UPDATES the shadow directory to look like the tree that HEAD refers to
Aborts if there are modifications in tracked files
reset - UPDATES a branch (may leave a commit to be orphaned!)
UPDATES the shadow directory
--hard UPDATES the working directory (does NOT abort if there are modifications in tracked files)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment