tarc git guest_lecture

43
GIT: VERSION CONTROL TAR COLLEGE GUEST LECTURE By / Founder & CTO Neruti Technology Sdn Bhd Cheng Ping Onn @pocheng

Upload: ping-onn-cheng

Post on 15-Apr-2017

236 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Tarc git guest_lecture

GIT: VERSION CONTROLTAR COLLEGE GUEST LECTUREBy   / 

Founder & CTO

Neruti Technology Sdn Bhd

Cheng Ping Onn @pocheng

Page 2: Tarc git guest_lecture

INTRODUCTION

Neruti Technology Sdn BhdGit ­ High Level Introduction

Page 3: Tarc git guest_lecture

NERUTI TECHNOLOGY

Build cloud­based regulatory compliance and risk managemen softwareHighly regulated industriesnode.js, message queue, cloud foundry, no­sql, Agile (Scrum)backbone.js, bootstrap.js, SASSWe are HIRING!

Page 4: Tarc git guest_lecture

GIT ­ INTRODUCTION

What's Version Control?Why?Philosophy

distributedcompletenessscalabilityaccountabilityimmutability

Page 5: Tarc git guest_lecture

WHO USES GIT

Page 6: Tarc git guest_lecture

CENTRALIZED VC

Page 7: Tarc git guest_lecture

DISTRIBUTED VC

Page 8: Tarc git guest_lecture

BASIC CONCEPT

Content tracking systemNo temporal (time) concept

Page 9: Tarc git guest_lecture

BASIC CONCEPT...CONT

Direct Acyclic Graph (DAG)

Page 10: Tarc git guest_lecture

COMMIT WORKFLOW

Page 11: Tarc git guest_lecture

FILE CLASSIFICATION

TrackedIn rep/index

IgnoredIn .gitignore

UntrackedNot in tracked/ignored

Page 12: Tarc git guest_lecture

BASIC CONFIGURATION

Duration: 5 minutes

$ git config --global user.name "Cheng Ping Onn"$ git config --global user.email [email protected] $ git config --listuser.name=Cheng Ping [email protected]=0core.filemode=truecore.bare=falsecore.logallrefupdates=true

Page 13: Tarc git guest_lecture

DEFAULT EDITOR CONFIGURATION

Duration: 2 minutes

$ git config --global core.editor vim

Page 14: Tarc git guest_lecture

CONFIGURE ALIAS

Duration: 3 minutes

$ git config --global alias.s status -s$ git config –global alias.lg 'log --oneline --all --graph --decorate'

Page 15: Tarc git guest_lecture

CONFIGURE AUTOCRLF

Duration: 3 minutes

$ git config –global core.autocrlf input

$ git config --listuser.name=Cheng Ping [email protected]=vimalias.s=statuspush.default=simplecore.repositoryformatversion=0core.filemode=truecore.bare=falsecore.logallrefupdates=truecore.autocrlf=inputalias.lg=log --oneline --all --graph --decorate

Page 16: Tarc git guest_lecture

COMMIT

Atomic changesetMust have commit messageExplicit reference ­ SHA1 hashImplicit reference ­ HEAD

Page 17: Tarc git guest_lecture

RELATIVE COMMIT NAME

master^ == master^1 == master~1master^^ == master^1^1 == master~2

Page 18: Tarc git guest_lecture

DEMO

initializationstaging

unstaging everythingunstaging a file

view indexcommit

relative namereset (delete commit, make sure you know what you are doing!)

Page 19: Tarc git guest_lecture

CREATE REPO AND COMMIT

Duration: 5 minutes

$ git init tarc$ cd tarc$ git status$ touch index.html$ git status$ git add index.html$ git status$ touch index.css$ git status$ git add .$ git status$ git commit -m'added homepage'$ git status

Page 20: Tarc git guest_lecture

STAGING

Duration: 5 minutes

$ touch about.html about.css contact.html contact.css$ ls$ git status$ git add ab*$ git s$ git commit -m'added about us page'$ git add .$ git commit -m'added contact page'

Page 21: Tarc git guest_lecture

SHA1 HASH

Probability of Collision160 bits = 2^160 ~ 10^80 hashes

A trillion people, trillion unique hashes/sec for a trillion years = 10^43Avalanche effect

Page 22: Tarc git guest_lecture

OBJECT STORE

Blobsany dataopaqueno metadata

Treesdirectory info

CommitsAuthor, committer, data, log

Tagshuman readable indicator

Page 23: Tarc git guest_lecture

OBJECT STORE ­ INITIAL COMMIT

Page 24: Tarc git guest_lecture

OBJECT STORE ­ SUBSEQUENT COMMIT

Page 25: Tarc git guest_lecture

DEMO

view object storeview blobsview treesview commits

Page 26: Tarc git guest_lecture

BRANCHING

Page 27: Tarc git guest_lecture

BRANCH REACHABILITY

Page 28: Tarc git guest_lecture

DEMO

create branchcreate and checkout branchdetached head

Page 29: Tarc git guest_lecture

CREATE & CHECKOUT BRANCH

Duration: 3 minutes

$ git branch$ git branch search$ git checkout search$ touch search.html search.css$ git add .$ git commit -m'added search page'$ git lg$ git checkout master$ ls

Page 30: Tarc git guest_lecture

DETACHED HEAD

Duration: 3 minutes

// git checkout a previous commit$ git lg$ touch new.html$ git add .$ git commit -m'added new file'$ git lg$ git branch

Page 31: Tarc git guest_lecture

MERGE

fast­forwardsharing same ancestor lineage

recursive ­ non fast­forwarddifferent merge base

Page 32: Tarc git guest_lecture

FAST FORWARD MERGE 1/3

Page 33: Tarc git guest_lecture

FAST FORWARD MERGE 2/3

Page 34: Tarc git guest_lecture

FAST FORWARD MERGE FINAL

Page 35: Tarc git guest_lecture

RECURSIVE MERGE 1/2

Page 36: Tarc git guest_lecture

RECURSIVE MERGE FINAL

Page 37: Tarc git guest_lecture

DEMO

fast­forward mergerecursive merge

Page 38: Tarc git guest_lecture

FAST FORWARD MERGE

Duration: 5 minutes

//Add student branch$ git checkout master$ git checkout -b student$ git branch$ touch student.html$ git add .$ git commit -m'added student page'

//Add alumni branch$ git checkout master$ git checkout -b alumni$ touch alumni.html$ git add .$ git commit -m 'added alumni page'$ history$ git lg

//Fast-Forward Merge$ git checkout master$ git merge alumni$ git branch -d alumni$ git lg

Page 39: Tarc git guest_lecture

RECURSIVE MERGE

Duration: 3 minutes

$ git branch //verify to be in master branch$ git merge student$ git lg

Page 40: Tarc git guest_lecture

CAVEAT OF GIT

Page 41: Tarc git guest_lecture

traditionally, not suitable for large binary filenew effort to support large binary file

Page 42: Tarc git guest_lecture

TOOLS USED IN THIS PRESENTATION

Ubuntu LinuxVIMVIM Plugin ­ fugitive.vimPresentation ­ reveal.js, npm,grunt

Page 43: Tarc git guest_lecture

THANK YOU!Cheng Ping Onn Founder & [email protected], @pocheng Neruti Technology Sdn Bhd