git 201 - a deeper look at git @ mdc 2016

37
GIT 201 - A DEEPER LOOK AT GIT Git Me With Your Best Shot rthur Doler @arthurdoler [email protected]

Upload: arthur-doler

Post on 06-Apr-2017

110 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Git 201 - A Deeper Look at Git @ MDC 2016

GIT 201 - A DEEPER LOOK AT GIT

Git Me With Your Best Shot

Arthur Doler @arthurdoler [email protected]

Page 2: Git 201 - A Deeper Look at Git @ MDC 2016

We’ll be using the Git command line…

Source: Giphy

Page 3: Git 201 - A Deeper Look at Git @ MDC 2016

“FUNDAMENTAL PARTICLES” OF GIT

Page 4: Git 201 - A Deeper Look at Git @ MDC 2016

Blob

artdoler@machine$ git ls-files --stage100644 ac461d89cb0a217c2ee2bfcac33e1c27df7739a7 0 path/to/source/file.js

Page 5: Git 201 - A Deeper Look at Git @ MDC 2016

Tree

artdoler@machine$ git write-treecf09c37fdb1e4ba320d2ae08e9eb32d6913979e3

artdoler@machine$ git ls-tree cf09040000 tree c98ef89a1fc979e593927666c058d15f8111c0bf path

Page 6: Git 201 - A Deeper Look at Git @ MDC 2016

Commit

artdoler@machine$ echo "Manual commit." | git commit-tree cf09c26db2aec27b78aeaed82173ec5f5b2303931b29

artdoler@machine$ git log c26dcommit c26db2aec27b78aeaed82173ec5f5b2303931b29Author: Art Doler [email protected]: Thu May 20 08:59:12 2016 -0500 Manual commit.

Page 7: Git 201 - A Deeper Look at Git @ MDC 2016

A GIT REPOSITORY

IS JUST GRAPHS OF COMMITS

Page 8: Git 201 - A Deeper Look at Git @ MDC 2016

What Git Manages For You

What To Actually Think About

Blob

Tree

Commit

Δ

Δ

Δ

Δ

Δ

Δ

Δ

Δ

ΔΔ

ΔΔ

Δ

Page 9: Git 201 - A Deeper Look at Git @ MDC 2016

HOW DOES GIT MAKE DIFFS?

Page 10: Git 201 - A Deeper Look at Git @ MDC 2016

B

C

F

E

AFile 1

File 3

File 4

File 5

Commit 1 Commit 2File 2

File 4

Directory Directory

Rename

Delete

EditAdd

Page 11: Git 201 - A Deeper Look at Git @ MDC 2016

BRANCHES & TAGS

When I realize “DVCS” means I always get my own branch

Source: Giphy

Page 12: Git 201 - A Deeper Look at Git @ MDC 2016

WHAT’S IN A NAME?

Page 13: Git 201 - A Deeper Look at Git @ MDC 2016

HEAD

ac461d89cb0a217c2ee2bfcac33e1c27df7739a7

feature/my_feature_branch

^ ~

Page 14: Git 201 - A Deeper Look at Git @ MDC 2016

B = A^ = A~ = A^1 = A~1

A

B

A = A^0

C

C = B^ = A^^ = A~~ C = A^1^1 = A~2C ≠ A^2

develop

Page 15: Git 201 - A Deeper Look at Git @ MDC 2016

MERGING

When my coworker’s merge breaks my feature

Source: Giphy

Page 16: Git 201 - A Deeper Look at Git @ MDC 2016

B = A^ = A~ = A^1 = A~1

A

B

A = A^0

C

D E

D = C^1 = C~ = B~2

develop

E = C^2 = B^^2 = A~2^2

develop branch_2

F G

F = C^^ = A~4

G = E~ = C^2^ = A~2^2~

C = B^ = A^^ = A~~ C = A^1^1 = A~2C ≠ A^2

Page 17: Git 201 - A Deeper Look at Git @ MDC 2016

OPINION TIMESource: Giphy

Page 18: Git 201 - A Deeper Look at Git @ MDC 2016

IF THE BEST WAY TO THINK ABOUT GIT IS COMMIT

TOPOLOGIES…

Page 19: Git 201 - A Deeper Look at Git @ MDC 2016

ONE CONCEPT, ONE COMMIT

Page 20: Git 201 - A Deeper Look at Git @ MDC 2016

“I don't know how many people look at Al's progression of patches, but they are stand-alone patches on their own, while at the same time _also_ being part of a larger migration to the inscrutable goals of Al - ie namespaces etc.

You may not realize just _how_ impressive that is, and what a absolute wonder it is to work with the guy.

Poetry in patches, indeed.” - Linus Torvalds On fa.linux.kernel, 27 Dec 2001

Source: Wikipedia

Page 21: Git 201 - A Deeper Look at Git @ MDC 2016

CLEAN CODE ↔ CLEAN HISTORY

Page 22: Git 201 - A Deeper Look at Git @ MDC 2016

PICK “TOO MANY COMMITS” OVER “TOO FEW”

Page 23: Git 201 - A Deeper Look at Git @ MDC 2016

“History is the version of past events that people have decided to agree upon.” - Attr. Napoleon Bonaparte

Source: Wikipedia

Page 24: Git 201 - A Deeper Look at Git @ MDC 2016

REBASING

When you learn to rebase like a boss

Source: Giphy

Page 25: Git 201 - A Deeper Look at Git @ MDC 2016

PUBLIC VERSUS PRIVATE BRANCHES

Page 26: Git 201 - A Deeper Look at Git @ MDC 2016

When you force push to a

public branchSource: Giphy

Page 27: Git 201 - A Deeper Look at Git @ MDC 2016

GARBAGE COLLECTION

Finding out git has a garbage collector when it deletes your accidentally

untracked branch

Source: Giphy

Page 28: Git 201 - A Deeper Look at Git @ MDC 2016

HISTORY METHODOLOGIES

Page 29: Git 201 - A Deeper Look at Git @ MDC 2016

Pure Merge (i.e. gitflow)Pure Rebase (Keep Branch or Delete Branch)Rebase Then MergeRebase With Squash (Mild/Major)

… A

D

E

F

Example Case: Feature

Develop… B

Page 30: Git 201 - A Deeper Look at Git @ MDC 2016

F

Pure Merge

A

C D

E

G

Develop

Feature

B

Page 31: Git 201 - A Deeper Look at Git @ MDC 2016

Pure Rebase(Keep or Delete Branch)

A

B C

D

Develop

Feature

Page 32: Git 201 - A Deeper Look at Git @ MDC 2016

Rebase Then Merge

A

C D

E

Develop

Feature

B

F

Page 33: Git 201 - A Deeper Look at Git @ MDC 2016

A

B D

E

Develop

FeatureFRebase With Squash

Page 34: Git 201 - A Deeper Look at Git @ MDC 2016

THANKS

When I accidentally click ‘Merge pull

request’ instead of ‘Comment’ in GitHub

Source: Giphy

Page 35: Git 201 - A Deeper Look at Git @ MDC 2016

Arthur Doler

@arthurdoler

[email protected]

Page 36: Git 201 - A Deeper Look at Git @ MDC 2016

RESOURCES

Page 37: Git 201 - A Deeper Look at Git @ MDC 2016

• Git from the Bottom Up (free!)• http://ftp.newartisans.com/pub/git.from.bottom.up.pdf

• Gitflow• http://nvie.com/posts/a-successful-git-branching-model/

• A Git Workflow for Agile Teams• http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html

• Git Team Workflows: merge or rebase?• http://blogs.atlassian.com/2013/10/git-team-workflows-merge-or-rebase/

• Git Pro Book (also free!)• http://git-scm.com/book

• Git pack files• http://git-scm.com/book/en/Git-Internals-Packfiles• http://stackoverflow.com/questions/5176225/are-gits-pack-files-deltas-rathe...