In his talk, Scott focuses on demystifying git’s
reset command through an explanation of git’s three trees:
index, and the
working tree. Toward the end of the talk, he also includes some of Git’s plumbing goodies that can be useful in local scripts for automatic backup, cleaning past commits, and so forth.
Hope you enjoy the notes. As always, I typed quickly and so guarantee absolutely no accuracy. You might reference these notes with his slides (warning: PDF).
rmall files, and
git commitwould still work just fine
git statustells you the diff of the three trees
git reset [file]
git add [file]
HEADand make index look like that
git reset [commit]
git reset --soft HEAD~
HEAD~: parent of
[--mixed]: then copy to index
HEADis pointing at and makes your index look like that.
--hard– then copy to work dir
git reset --soft HEAD~2; git commit
HEADback tw ocommits, keep index
git checkout [commit] [path]
git checkout [commit]
git reset masterwill move your index to where the branch started
git checkout masterwill move
HEADto point to master
git add --patch [file]
git reset --patch (commit) [file]
git checkout --patch (commit) [file]
git add -p
git commit --amend==
git reset --soft HEAD~; git commit ...
git log --stat (branch)
git rev-parse origin/master
git rev-parse master~163^2~3^2– walks backwards, does some cool stuff. Figures out its SHA.
git rev-parse master~163^2~3^2..origin/master
git hash-object -w ~/.sshid_rsa.pub
echo 'my awesome value' | git hash-object -w --stdin
git ls-files -s: shows you your staging area
git ls-files -s # show index git ls-files -r HEAD # show index git read-tree HEAD~2 # basically same as git reset
git write-tree: tells you the tree that a commit would make if you commited it.
echo 'my commit message' | git commit-tree
git update-ref refs/heads/newbranch
git symbolic-ref HEAD refs/heads/newbranch