Slide 1

Slide 1 text

So You Think You Know Git? Co-founder of GitHub / GitButler Scott Chacon part 2

Slide 2

Slide 2 text

About Me

Slide 3

Slide 3 text

github.com About Me

Slide 4

Slide 4 text

git-scm.com/book github.com About Me

Slide 5

Slide 5 text

git-scm.com/book gitbutler.com github.com About Me

Slide 6

Slide 6 text

- There are ~145 commands in Git - There are still an average of 9 commits per day - ~10k commits in the last 3 years - Do you know it all? How Well Do You Know Git?

Slide 7

Slide 7 text

Let's Do This

Slide 8

Slide 8 text

-switch and restore -hooks -attributes, smudge and clean filters -fixup commits -rebasing stacks -scalar -worktrees Let's Do This

Slide 9

Slide 9 text

Let's Do This -switch and restore -hooks -attributes, smudge and clean filters -fixup commits -rebasing stacks -scalar -worktrees Shotgun buffet

Slide 10

Slide 10 text

Let's Do This Shotgun buffet blog.gitbutler.com -switch and restore -hooks -attributes, smudge and clean filters -fixup commits -rebasing stacks -scalar -worktrees

Slide 11

Slide 11 text

Switch and Restore

Slide 12

Slide 12 text

Switch and Restore ❯ git checkout branch ❯ git checkout file.txt ❯ git checkout HEAD@{10.minutes.ago} -- file.txt ❯ git checkout -p file.txt

Slide 13

Slide 13 text

Switch and Restore ❯ git checkout branch ❯ git switch branch ❯ git switch -c new_branch

Slide 14

Slide 14 text

Switch and Restore ❯ git checkout file.txt ❯ git restore file.txt ❯ git restore -- source HEAD@{10.minutes.ago} file.txt ❯ git restore -p file.txt

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Hooks

Slide 22

Slide 22 text

Hooks - applypatch-msg - pre-applypatch - post-applypatch - pre-commit - pre-merge-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-checkout - post-merge - pre-push - pre-receive - update - proc-receive - post-receive - post-update - reference-transaction - push-to-checkout - pre-auto-gc - post-rewrite - sendemail-validate - fsmonitor-watchman - p4-changelist - p4-prepare-changelist - p4-post-changelist - p4-pre-submit - post-index-change (28)

Slide 23

Slide 23 text

Hooks - applypatch-msg - pre-applypatch - post-applypatch - pre-commit - pre-merge-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-checkout - post-merge - pre-push - pre-receive - update - proc-receive - post-receive - post-update - reference-transaction - push-to-checkout - pre-auto-gc - post-rewrite - sendemail-validate - fsmonitor-watchman - p4-changelist - p4-prepare-changelist - p4-post-changelist - p4-pre-submit - post-index-change (24) (- git email stuff)

Slide 24

Slide 24 text

Hooks - applypatch-msg - pre-applypatch - post-applypatch - pre-commit - pre-merge-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-checkout - post-merge - pre-push - pre-receive - update - proc-receive - post-receive - post-update - reference-transaction - push-to-checkout - pre-auto-gc - post-rewrite - sendemail-validate - fsmonitor-watchman - p4-changelist - p4-prepare-changelist - p4-post-changelist - p4-pre-submit - post-index-change (20) (- perforce stuff)

Slide 25

Slide 25 text

Hooks - applypatch-msg - pre-applypatch - post-applypatch - pre-commit - pre-merge-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-checkout - post-merge - pre-push - pre-receive - update - proc-receive - post-receive - post-update - reference-transaction - push-to-checkout - pre-auto-gc - post-rewrite - sendemail-validate - fsmonitor-watchman - p4-changelist - p4-prepare-changelist - p4-post-changelist - p4-pre-submit - post-index-change (14) (- server stuff)

Slide 26

Slide 26 text

Hooks - applypatch-msg - pre-applypatch - post-applypatch - pre-commit - pre-merge-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-checkout - post-merge - pre-push - pre-receive - update - proc-receive - post-receive - post-update - reference-transaction - push-to-checkout - pre-auto-gc - post-rewrite - sendemail-validate - fsmonitor-watchman - p4-changelist - p4-prepare-changelist - p4-post-changelist - p4-pre-submit - post-index-change (11) (- MS scaling stuff)

Slide 27

Slide 27 text

Hooks - applypatch-msg - pre-applypatch - post-applypatch - pre-commit - pre-merge-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-checkout - post-merge - pre-push - pre-receive - update - proc-receive - post-receive - post-update - reference-transaction - push-to-checkout - pre-auto-gc - post-rewrite - sendemail-validate - fsmonitor-watchman - p4-changelist - p4-prepare-changelist - p4-post-changelist - p4-pre-submit - post-index-change (11)

Slide 28

Slide 28 text

Hooks - pre-commit - prepare-commit-msg - commit-msg - post-commit - pre-rebase - post-rewrite - post-merge - pre-merge-commit - post-checkout - reference-transaction - pre-push (11) Commit Stuff Rewriting Stuff Merging Stuff Switching/Pushing Stuff

Slide 29

Slide 29 text

Hooks: Examples - commit message formatting - package install - update ctags - submodule status - tabs or spaces - linting - large files - test passes - rebasing merged commit prevention

Slide 30

Slide 30 text

Hooks: Helpers - pre-commit - husky

Slide 31

Slide 31 text

Hooks: pre-commit ❯ brew install pre-commit ❯ pre-commit sample-config > .pre-commit-config.yaml ❯ pre-commit install

Slide 32

Slide 32 text

Hooks: pre-commit ❯ brew install pre-commit

Slide 33

Slide 33 text

Hooks: pre-commit ❯ brew install pre-commit

Slide 34

Slide 34 text

Hooks: pre-commit ❯ brew install pre-commit

Slide 35

Slide 35 text

Hooks: husky ❯ npm install -- save-dev husky ❯ npx husky init

Slide 36

Slide 36 text

Hooks: husky ❯ npm install -- save-dev husky ❯ npx husky init

Slide 37

Slide 37 text

Hooks: husky ❯ npm install -- save-dev husky ❯ npx husky init

Slide 38

Slide 38 text

Attributes

Slide 39

Slide 39 text

Attributes ❯ git diff diff -- git a/image.png b/image.png index 88839c4 .. 4afcb7c 100644 Binary files a/image.png and b/image.png differ

Slide 40

Slide 40 text

Attributes ❯ exiftool image.png ExifTool Version Number : 7.74 File Name : image.png Directory : . File Size : 94 kB File Modification Date/Time : 2009 : 04 : 21 07 : 02 : 43-07 : 00 File Type : PNG MIME Type : image/png Image Width : 1056 Image Height : 827 Bit Depth : 8 Color Type : RGB with Alpha Compression : Deflate/Inflate Filter : Adaptive Interlace : Noninterlaced Profile CMM Type : appl

Slide 41

Slide 41 text

Attributes ❯ echo '*.png diff=exif' >> .gitattributes # take every file that ends in png # and pre-process them with a strategy called ‘exif’ ❯ git config diff.exif.textconv exiftool # the 'exif' strategy is to run exiftool on the file

Slide 42

Slide 42 text

Attributes ❯ echo '*.png diff=exif' >> .gitattributes # take every file that ends in png # and pre-process them with a strategy called ‘exif’ ❯ git config diff.exif.textconv exiftool # the 'exif' strategy is to run exiftool on the file

Slide 43

Slide 43 text

Smudge and Clean

Slide 44

Slide 44 text

Smudge and Clean

Slide 45

Slide 45 text

Smudge and Clean

Slide 46

Slide 46 text

Smudge and Clean

Slide 47

Slide 47 text

Smudge and Clean

Slide 48

Slide 48 text

Smudge and Clean

Slide 49

Slide 49 text

Smudge and Clean

Slide 50

Slide 50 text

Smudge and Clean: RCS Keywords

Slide 51

Slide 51 text

Smudge and Clean: RCS Keywords / * $Id$ $Header$ $Date$ $DateTime$ $Change$ $File$ $Revision$ $Author$ * /

Slide 52

Slide 52 text

Smudge and Clean: RCS Keywords / * $Id: // depot/test/main.c#10 $ $Header: // depot/test/main.c#10 $ $Date: 2006/06/21 $ $DateTime: 2006/06/21 17 : 42 : 19 $ $Change: 1745 $ $File: / / depot/test/main.c $ $Revision: #10 $ $Author: michael $ / *

Slide 53

Slide 53 text

Smudge and Clean: $Date$

Slide 54

Slide 54 text

Smudge and Clean: $Date$

Slide 55

Slide 55 text

Smudge and Clean: $Date$

Slide 56

Slide 56 text

Smudge and Clean: $Date$

Slide 57

Slide 57 text

Smudge and Clean: $Date$

Slide 58

Slide 58 text

Smudge and Clean: $Date$

Slide 59

Slide 59 text

Smudge and Clean: $Date$

Slide 60

Slide 60 text

Smudge and Clean: $Date$

Slide 61

Slide 61 text

Smudge and Clean: LFS

Slide 62

Slide 62 text

Smudge and Clean: LFS

Slide 63

Slide 63 text

Smudge and Clean: LFS ❯ brew install git-lfs ❯ git lfs install Updated Git hooks. Git LFS initialized. ❯ git lfs track "*.mov" Tracking "*.mov" ❯ git commit -am 'commit movie' [master c0258ddeba] commit movie 1 files changed, 83 insertions(+) create mode 100644 Timeline 1.mov

Slide 64

Slide 64 text

Smudge and Clean: LFS ❯ brew install git-lfs ❯ git lfs install Updated Git hooks. Git LFS initialized. ❯ git lfs track "*.mov" Tracking "*.mov" ❯ git commit -am 'commit movie' [master c0258ddeba] commit movie 1 files changed, 83 insertions(+) create mode 100644 Timeline 1.mov

Slide 65

Slide 65 text

Smudge and Clean: LFS ❯ brew install git-lfs ❯ git lfs install Updated Git hooks. Git LFS initialized. ❯ git lfs track "*.mov" Tracking "*.mov" ❯ git commit -am 'commit movie' [master c0258ddeba] commit movie 1 files changed, 83 insertions(+) create mode 100644 Timeline 1.mov

Slide 66

Slide 66 text

Smudge and Clean: LFS ❯ brew install git-lfs ❯ git lfs install Updated Git hooks. Git LFS initialized. ❯ git lfs track "*.mov" Tracking "*.mov" ❯ git commit -am 'commit movie' [master c0258ddeba] commit movie 1 files changed, 83 insertions(+) create mode 100644 Timeline 1.mov

Slide 67

Slide 67 text

Smudge and Clean: LFS ❯ git cat-file -p HEAD:"Timeline 1.mov" version https: // git-lfs.github.com/spec/v1 oid sha256 : 683d9e177ed4694aa8e99a0de86a79fb929805f5799d036cd4dfe11aa0dc1a97 size 508537858 ❯ cat .gitattributes *.mov filter=lfs diff=lfs merge=lfs -text

Slide 68

Slide 68 text

Smudge and Clean: LFS ❯ git cat-file -p HEAD:"Timeline 1.mov" version https: // git-lfs.github.com/spec/v1 oid sha256 : 683d9e177ed4694aa8e99a0de86a79fb929805f5799d036cd4dfe11aa0dc1a97 size 508537858 ❯ cat .gitattributes *.mov filter=lfs diff=lfs merge=lfs -text

Slide 69

Slide 69 text

Fixup Commits

Slide 70

Slide 70 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 71

Slide 71 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 72

Slide 72 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 73

Slide 73 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 74

Slide 74 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 75

Slide 75 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 76

Slide 76 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 77

Slide 77 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 78

Slide 78 text

No content

Slide 79

Slide 79 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 80

Slide 80 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 81

Slide 81 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 82

Slide 82 text

Fixup Commits git commit -- fixup= git rebase -- autosquash

Slide 83

Slide 83 text

Rebasing Stacks

Slide 84

Slide 84 text

Rebasing Stacks git rebase -- update-refs

Slide 85

Slide 85 text

Rebasing Stacks git rebase -- update-refs

Slide 86

Slide 86 text

Rebasing Stacks git rebase -- update-refs

Slide 87

Slide 87 text

Rebasing Stacks git rebase -- update-refs

Slide 88

Slide 88 text

Rebasing Stacks git rebase -- update-refs

Slide 89

Slide 89 text

Rebasing Stacks git rebase -- update-refs

Slide 90

Slide 90 text

Rebasing Stacks git rebase -- update-refs

Slide 91

Slide 91 text

Rebasing Stacks git rebase -- update-refs

Slide 92

Slide 92 text

Rebasing Stacks git rebase -- update-refs

Slide 93

Slide 93 text

Rebasing Stacks git rebase -- update-refs

Slide 94

Slide 94 text

Rebasing Stacks git rebase -- update-refs

Slide 95

Slide 95 text

Rebasing Stacks git rebase -- update-refs

Slide 96

Slide 96 text

Update Refs by Default ❯ git config rebase.updateRefs true

Slide 97

Slide 97 text

Scaling Git

Slide 98

Slide 98 text

Scaling Git ❯ scalar usage: scalar [-C ] [-c = ] [< options >] Commands: clone list register unregister run reconfigure delete help version diagnose

Slide 99

Slide 99 text

Scaling Git ❯ scalar usage: scalar [-C ] [-c = ] [< options >] Commands: clone list register unregister run reconfigure delete help version diagnose

Slide 100

Slide 100 text

Scaling Git: Scalar -prefetching -commit-graph -filesystem monitor -partial cloning -sparse checkout ❯ scalar clone [email protected]:schacon/huge-project.git

Slide 101

Slide 101 text

Worktrees

Slide 102

Slide 102 text

Worktrees - working on more than one branch at a time - provide a new working directory for each branch

Slide 103

Slide 103 text

Worktrees

Slide 104

Slide 104 text

git worktree add

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

No content

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

git worktree list

Slide 109

Slide 109 text

GitButler gitbutler.com

Slide 110

Slide 110 text

GitButler

Slide 111

Slide 111 text

No content

Slide 112

Slide 112 text

No content

Slide 113

Slide 113 text

No content

Slide 114

Slide 114 text

No content

Slide 115

Slide 115 text

No content

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

For even more... Another 45 minutes of this ridiculousness youtube.com/@gitbutlerapp

Slide 118

Slide 118 text

Thank you! Be sure to let us buy you a beer at our drinkup tonight! B'Femme, 7p

Slide 119

Slide 119 text

Be sure to let us buy you a beer at our drinkup tonight! B'Femme, 6p