Slide 1

Slide 1 text

Adopt Git at Scale and Stay Sane Lars Schneider Technical Lead GitHub Solutions Autodesk larsxschneider kit3bus [email protected]

Slide 2

Slide 2 text

Adopting Git is a Challenge ... 4000 engineers

Slide 3

Slide 3 text

Today's topics? 1. Ease Git on-boarding 2. Git usage recommendations 3. Git usage monitoring

Slide 4

Slide 4 text

What protocol to use? HTTPS SSH Git No authentication Difficult on Windows

Slide 5

Slide 5 text

What protocol to use? HTTPS SSH Git Recommended

Slide 6

Slide 6 text

HTTPS protocol $ git clone https://autodesk.com/myorg/myrepo Cloning into 'myrepo'... Username for 'https://autodesk.com': "Why do I have to type my password all the time?"

Slide 7

Slide 7 text

HTTPS protocol $ git clone https://autodesk.com/myorg/myrepo Cloning into 'myrepo'... Username for 'https://autodesk.com': Git Credential Helper Solution "Why do I have to type my password all the time?"

Slide 8

Slide 8 text

User Config "Why are my commits not associated to me?"

Slide 9

Slide 9 text

User Config "Why are my commits not associated to me?" $ git config --global user.name "Lars Schneider" $ git config --global user.email [email protected] Setup user!

Slide 10

Slide 10 text

Insight Trivial tasks performed by 4000 people generate many support tickets.

Slide 11

Slide 11 text

Enterprise Config for Git Painless Git setup with an easy way to share Git configs and scripts within a company.

Slide 12

Slide 12 text

Enterprise Config for Git $ git [setup command]

Slide 13

Slide 13 text

Enterprise Config for Git $ git adsk

Slide 14

Slide 14 text

Enterprise Config for Git $ git adsk Setup credential helper Check Git / Git LFS versions Self update Local user setup

Slide 15

Slide 15 text

Enterprise Config for Git $ git adsk Setup credential helper Check Git / Git LFS versions Self update Local user setup Too lazy to type? Go here: git.io/vajMI $ printf "protocol=https\nhost=github.com\n\n" | 
 git credential-$(git config credential.helper) get


Slide 16

Slide 16 text

Enterprise Config for Git $ git adsk Setup credential helper Check Git / Git LFS versions Self update Local user setup $ printf "protocol=https\nhost=github.com\n\n" | 
 git credential-$(git config credential.helper) get
 password=SECRET123 username=larsxschneider Oh...

Slide 17

Slide 17 text

Enterprise Config for Git $ git adsk Setup credential helper with token Check Git / Git LFS versions Self update Local user setup

Slide 18

Slide 18 text

Enterprise Config for Git $ git adsk Check signed Source Code Agreement ... Setup credential helper with token Check Git / Git LFS versions Self update Local user setup

Slide 19

Slide 19 text

Enterprise Config for Git [alias] adsk = "!f() { \ GIT_KIT=$(dirname $(git config include.path)) && \ bash \"$GIT_KIT/setup.sh\" \ }; f" File: /Users/lars/.enterprise/config.include New Git command! [include] path = /Users/lars/.enterprise/config.include File:~/.gitconfig Engineers global
 Git config

Slide 20

Slide 20 text

Enterprise Config for Git $ git clone https://autodesk.com/enterprise.git ~/.enterprise $ git config --global include.path ~/.enterprise/config.include Install: ... works on Windows, too. However, we made a custom version of the great Git for Windows Installer.

Slide 21

Slide 21 text

Enterprise Config for Git github.com/autodesk/enterprise-config-for-git

Slide 22

Slide 22 text

Git Usage Recommendations

Slide 23

Slide 23 text

Git Usage Recommendations 1. Create branches

Slide 24

Slide 24 text

Git Usage Recommendations 1. Create branches 2. Push often

Slide 25

Slide 25 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase)

Slide 26

Slide 26 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!)

Slide 27

Slide 27 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!) 5. Configure gitignore (use gitignore.io)

Slide 28

Slide 28 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!) 5. Configure gitignore (use gitignore.io) 6. Avoid many files (> 100k hurts performance)

Slide 29

Slide 29 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!) 5. Configure gitignore (use gitignore.io) 6. Avoid many files (> 100k hurts performance) 7. Use Submodules (use automation; avoid nesting; avoid >25 per repo)

Slide 30

Slide 30 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!) 5. Configure gitignore (use gitignore.io) 6. Avoid many files (> 100k hurts performance) 7. Use Submodules (use automation; avoid nesting; avoid >25 per repo) 8. Use Git-LFS for large files

Slide 31

Slide 31 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!) 5. Configure gitignore (use gitignore.io) 6. Avoid many files (> 100k hurts performance) 7. Use Submodules (use automation; avoid nesting; avoid >25 per repo) 8. Use Git-LFS for large files

Slide 32

Slide 32 text

Git Push Protection $ git clone https://github.com/larsxschneider/test.git $ ... $ git push Git push is scary in an enterprise environment.

Slide 33

Slide 33 text

Git Push Protection $ git clone https://github.com/larsxschneider/test.git $ ... $ git push fatal: '/// ATTENTION /// Do you want to push to github.com? Git push is scary in an enterprise environment.

Slide 34

Slide 34 text

Git Push Protection $ git clone https://github.com/larsxschneider/test.git $ ... $ git push fatal: '/// ATTENTION /// Do you want to push to github.com? Disable this warning with: 'git adsk enable-push github.com/ larsxschneider/test.git' Git push is scary in an enterprise environment.

Slide 35

Slide 35 text

Git Push Protection $ git clone https://github.com/larsxschneider/test.git $ ... $ git push fatal: '/// ATTENTION /// Do you want to push to github.com? Disable this warning with: 'git adsk enable-push github.com/ larsxschneider/test.git' does not appear to be a git repository fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. Use git config URL rewrite to create a warning: [url "/// ATTENTION /// Do you want to push to github.com? Disable this warning with: 'git adsk enable-push github.com"] pushInsteadOf = "https://github.com" File: /Users/lars/.enterprise/config.include 1 2

Slide 36

Slide 36 text

Git Push Protection SourceTree

Slide 37

Slide 37 text

Git Push Protection SmartGit

Slide 38

Slide 38 text

Git Push Protection Google Summer of Code / Outreachy Project More info: https://git.github.io/SoC-2016-Ideas/ http://outreachy.org https://summerofcode.withgoogle.com

Slide 39

Slide 39 text

Git Usage Recommendations 1. Create branches 2. Push often 3. Merge instead of rebase (at least until you grok rebase) 4. Avoid cherry picking (a commit is no delta!) 5. Configure gitignore (use gitignore.io) 6. Avoid many files (> 100k hurts performance) 7. Use Submodules (use automation; avoid nesting; avoid >25 per repo) 8. Use Git-LFS for large files

Slide 40

Slide 40 text

Git and Large Files Files that change often and are large after compression are bad for Git.

Slide 41

Slide 41 text

Git and Large Files Files that change often and are large after compression are bad for Git. # binaries x avg. changes/year x avg. size in MB < 100 1000 x 1 x 0.05 = 25 10 x 365 x 0.05 = 183

Slide 42

Slide 42 text

Git LFS - fast clone $ git clone ... Downloading file1.bin (10 MB) Downloading file2.bin (40 MB) Downloading file3.bin (30 MB) ... Downloading file500.bin (20 MB) Takes ages!

Slide 43

Slide 43 text

Git LFS - fast clone – Rick Olsen (@technoweenie) “Use GIT_LFS_SKIP_SMUDGE and git-lfs pull to speed up cloning.”

Slide 44

Slide 44 text

Git LFS - fast clone Still slow! 13x faster!

Slide 45

Slide 45 text

Git LFS - fast clone $ git clone ... Downloading file1.bin (10 MB) Downloading file2.bin (40 MB) Downloading file3.bin (30 MB) ... Downloading file500.bin (20 MB) Takes ages! $ git adsk clone ... Git LFS: (500 of 500 files) Lightning fast!

Slide 46

Slide 46 text

Git LFS - fast clone

Slide 47

Slide 47 text

Git LFS - fast clone Wow!

Slide 48

Slide 48 text

Git Usage Monitoring

Slide 49

Slide 49 text

Git Usage Monitoring Log forwarding

Slide 50

Slide 50 text

Git Usage Monitoring host="" source="udp:514" sourcetype=syslog \"program\":\"upload-pack\" \"cloning\":true | rex "^.*github_audit\[\d+\]\:\s(?P.+)" | spath input=json | bucket_time span=1d | stats count BY user_id, repo_id, _time Who is cloning all the time? Log forwarding

Slide 51

Slide 51 text

Git Usage Monitoring host="" source="udp:514" sourcetype=syslog \"program\":\"upload-pack\" \"cloning\":true | rex "^.*github_audit\[\d+\]\:\s(?P.+)" | spath input=json | bucket_time span=1d | stats count BY user_id, repo_id, _time Who is cloning all the time? Log forwarding

Slide 52

Slide 52 text

Git Usage Monitoring /opt/backup-utils/bin/ghe-backup

Slide 53

Slide 53 text

Git Usage Monitoring /opt/backup-utils/bin/ghe-backup SELECT DATE_FORMAT(pull_requests.merged_at, '%Y-%m') AS date, 'Merged Pull Requests' AS type, COUNT(*) AS count FROM pull_requests AS pr, users WHERE pr.merged_at > (NOW() - INTERVAL 2 YEAR) AND pr.merged_at < DATE_FORMAT(CURRENT_DATE,'%Y-%m-01') AND user_id = users.id GROUP BY 1 ORDER BY 1,2 Merged Pull Requests per month?

Slide 54

Slide 54 text

Git Usage Monitoring /opt/backup-utils/bin/ghe-backup SELECT DATE_FORMAT(pull_requests.merged_at, '%Y-%m') AS date, 'Merged Pull Requests' AS type, COUNT(*) AS count FROM pull_requests AS pr, users WHERE pr.merged_at > (NOW() - INTERVAL 2 YEAR) AND pr.merged_at < DATE_FORMAT(CURRENT_DATE,'%Y-%m-01') AND user_id = users.id GROUP BY 1 ORDER BY 1,2 Merged Pull Requests per month?

Slide 55

Slide 55 text

Git Usage Monitoring /opt/backup-utils/bin/ghe-backup SELECT DATE_FORMAT(pull_requests.merged_at, '%Y-%m') AS date, 'Merged Pull Requests' AS type, COUNT(*) AS count FROM pull_requests AS pr, users WHERE pr.merged_at > (NOW() - INTERVAL 2 YEAR) AND pr.merged_at < DATE_FORMAT(CURRENT_DATE,'%Y-%m-01') AND user_id = users.id GROUP BY 1 ORDER BY 1,2 Merged Pull Requests per month?

Slide 56

Slide 56 text

Takeaways 1. Script your Git on-boarding 2. Credential helpers are not secure 3. Articulate Git usage recommendations 4. Monitor your Git usage

Slide 57

Slide 57 text

Enterprise Config for Git github.com/autodesk/enterprise-config-for-git

Slide 58

Slide 58 text

Adopt Git at Scale and Stay Sane Lars Schneider Technical Lead GitHub Solutions Autodesk larsxschneider kit3bus [email protected]