Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Windows demo script to accompany Grokking Git with Shakespeare
1. 1 Introduction
Repository, Working Tree and Index.
2 Git as a filesystem
Blobs are leaf nodes in a tree, with their name as a hash. Unlike a filesystem blobs have no metadata about their content. Files designed to
change, git blobs are immutable.
> mkdir sample
> cd sample
> "Hello, world!" | Out-File -Encoding utf8 greeting
Let's see what the blob name for greeting would be:
> git hash-object greeting
921a01483eff9b53ef5544c594f43a81157e1f53
> git init
> git add greeting
> git commit -m "Added my greeting"
Blob has been added into the system:
> git cat-file -t 921a0
blob
> git cat-file blob 921a0
> Hello, world!
3 Blobs are stored in trees
> git ls-tree HEAD
100644 blob 921a01483eff9b53ef5544c594f43a81157e1f53 greeting
100644 is a unix file mode, indicating a non-executable file. Others are:
040000 Directory
100664 Non-executable group-writeable file (deprecated)
100755 Regular executable file
120000 Symbolic link
160000 Gitlink
git rev-parse HEAD
> <commit>
git cat-file -t HEAD
> commit
git cat-file commit HEAD
> tree 2cf5c2815d718fcfe87dc75cd91288fa84e026e6
> author James World <james-> world@users.noreply.github.com> 1441056269 +0100
> committer James World <james-world@users.noreply.github.com> 1441056269 +0100
>
> Added my greeting
Show objects in folder:
gci -r .gitobjects | where {!$_.PSIsContainer} | ft FullName
4 How trees are made