ivo anjo
engineer-next-door @ talkdesk
...or (probably) (hopefully) (maybe)
the last presentation on git
you'll ever need!
...or (probably) (hopefully) (maybe)
the last presentation on git
you'll ever need!
follow along @
http://tinyurl.com/eye-doctor-here-i-go
repository ==
bunch of Directed Acyclic Graphs
of commits
sha1( )
~/some-git-repo/.git/refs$ tree
.
├── bisect
├── heads
│ ├── master
│ └── feature-branch
├── remotes
│ ├── origin
│ │ ├── master
│ │ └── feature-branch
│ ├── production
│ │ └── master
│ ├── qa
│ │ └── master
│ └── staging
│ └── master
├── stash
└── tags
~/some-git-repo/.git/refs$ tree
.
├── bisect
├── heads
│ ├── master -> ccc
│ └── feature-branch -> ddd
├── remotes
│ ├── origin
│ │ ├── master -> bbb
│ │ └── feature-branch -> ddd
│ ├── production
│ │ └── master -> aaa
│ ├── qa
│ │ └── master -> aaa
│ └── staging
│ └── master -> aaa
├── stash
└── tags
• create new
commit object
• hash it
• update branch file
.git/refs/heads/master -> bbb
.git/refs/heads/master -> ccc
• and then change the ref
file to point to from ccc to ddd
just changes the ref file to point to the new commit
$ git tag bestest-release-ever master
$ ls .git/refs/tags/
bestest-release-ever
$ cat .git/refs/tags/bestest-release-ever
c50f9ddda562e2777a68976ad7afbf83a72982f8
~/ruby/ivo-pry-debugger$ git reflog
11b1e1b HEAD@{0}: commit: Fix missing link in README
0542fa3 HEAD@{1}: rebase -i (finish): returning to refs/heads/master
0542fa3 HEAD@{2}: rebase -i (pick): Bump major version due to breaking changes (ruby compatibility)
537b2fb HEAD@{3}: rebase -i (pick): Drop support for older ruby versions (< 2.2.0)
c817891 HEAD@{4}: rebase -i (pick): Modernize codebase
03677c0 HEAD@{5}: rebase -i (pick): Add missing banners to avoid warnings in Pry code
aa67887 HEAD@{6}: rebase -i (pick): Avoid circular require when being loaded by pry
123da12 HEAD@{7}: rebase -i (fixup): README cleanups and updates
a51fbe7 HEAD@{8}: rebase -i (start): checkout origin/master
ed2e349 HEAD@{9}: rebase -i (finish): returning to refs/heads/master
ed2e349 HEAD@{10}: rebase -i (start): checkout master
ed2e349 HEAD@{11}: commit: fixup
4cf6d29 HEAD@{12}: commit: Bump major version due to breaking changes (ruby compatibility)
f741c04 HEAD@{13}: commit: Drop support for older ruby versions (< 2.2.0)
that is not a child of the previous ref
1. push
2. p --force-with-lease
1. push
2. your awesome colleague pushes
3. push --force-with-lease
You've just erased your colleague's work from the repository history
• This was working last deploy
• It's not working now
• git bisect does a binary search of git commits, and each time you tell it yay or nay
• the final output is the commit which
broke it
• can also run fully automated (e.g. run
rspec, watch result)