Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
1 Introduction
Repository, Working Tree and Index.
2 Git as a filesystem
Blobs are leaf nodes in a tree, with their name a...
rmdir -force .Sample
mkdir Sample
cd Sample
"Hello, world!" | Out-File > greeting
git init
git add greeting
git log (will ...
Patching and Interactive Rebasing
git checkout -b feature3
vim .File1.txt (Make sure Feature3 at top, Bug at bottom)
git a...
Upcoming SlideShare
Loading in …5
×

Windows demo script to accompany Grokking Git with Shakespeare

337 views

Published on

Demo script to accompany Grokking Git with Shakespeare slides. Use from Powershell with Git for windows and PoshGit available.

Published in: Software
  • Be the first to comment

  • Be the first to like this

Windows demo script to accompany Grokking Git with Shakespeare

  1. 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
  2. 2. rmdir -force .Sample mkdir Sample cd Sample "Hello, world!" | Out-File > greeting git init git add greeting git log (will fail) git ls-files --stage > 100644 921a01483eff9b53ef5544c594f43a81157e1f53 0 greeting subl ..gitindex (show hex) gci -r .gitobjects | where {!$_.PSIsContainer} | ft FullName git write-tree > 2cf5c2815d718fcfe87dc75cd91288fa84e026e6 "Initial commit" | git commit-tree 2cf5 > <commit> > "430ae264bfcd1e47a5003c4e359e9675cc7c1bd7" | Out-File -encoding ascii .git/refs/heads/master git symbolic-ref HEAD refs/heads/master Unreachability The beauty of commits Slide Merging Create new repo vim File1.txt ("File1") git add . git commit -m "File1" git checkout -b feature1 vim File1.txt ("Feature1") git checkout -b feature2 master vim File1.txt ("Feature2") git checkout master git merge --no-ff feature1 git lg (SLIDE) git reflog git reset --hard HEAD@{`1`} (Git GC etc) DIFFING SLIDES git log master..feature2 git log master...feature2 (Bit crap) git diff master..feature2 git diff master...feature2 (Very useful) git merge feature2 > MERGE CONFLICT! (Resolve it, show diamond, slide) Rebasing git reset --hard HEAD^ git checkout feature2 git rebase master (rerere) cat File1.txt git add File1.txt git rebase --continue git checkout master git merge feature2
  3. 3. Patching and Interactive Rebasing git checkout -b feature3 vim .File1.txt (Make sure Feature3 at top, Bug at bottom) git add -p File1.txt git diff git commit -m "Feature3" git add . git commit -m "Fixed bug" vim File1.txt (Feature3 Part2) git commit -am "Feature3-Part2" git checkout master git commit -am "Feature4" git checkout Feature3 git diff master... git diff master.. git rebase -i master (pick and squash) > conflict! (remote left and right swapped)

×