+ All Categories
Home > Software > Guest Lecture - GIT Version Control

Guest Lecture - GIT Version Control

Date post: 15-Apr-2017
Category:
Upload: ping-onn-cheng
View: 563 times
Download: 2 times
Share this document with a friend
43
GIT: VERSION CONTROL TAR COLLEGE GUEST LECTURE By / Founder & CTO Neruti Technology Sdn Bhd Cheng Ping Onn @pocheng
Transcript

GIT: VERSION CONTROLTAR COLLEGE GUEST LECTUREBy   / 

Founder & CTO

Neruti Technology Sdn Bhd

Cheng Ping Onn @pocheng

INTRODUCTION

Neruti Technology Sdn BhdGit ­ High Level Introduction

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!

GIT ­ INTRODUCTION

What's Version Control?Why?Philosophy

distributedcompletenessscalabilityaccountabilityimmutability

WHO USES GIT

CENTRALIZED VC

DISTRIBUTED VC

BASIC CONCEPT

Content tracking systemNo temporal (time) concept

BASIC CONCEPT...CONT

Direct Acyclic Graph (DAG)

COMMIT WORKFLOW

FILE CLASSIFICATION

TrackedIn rep/index

IgnoredIn .gitignore

UntrackedNot in tracked/ignored

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

DEFAULT EDITOR CONFIGURATION

Duration: 2 minutes

$ git config --global core.editor vim

CONFIGURE ALIAS

Duration: 3 minutes

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

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

COMMIT

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

RELATIVE COMMIT NAME

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

DEMO

initializationstaging

unstaging everythingunstaging a file

view indexcommit

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

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

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'

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

OBJECT STORE

Blobsany dataopaqueno metadata

Treesdirectory info

CommitsAuthor, committer, data, log

Tagshuman readable indicator

OBJECT STORE ­ INITIAL COMMIT

OBJECT STORE ­ SUBSEQUENT COMMIT

DEMO

view object storeview blobsview treesview commits

BRANCHING

BRANCH REACHABILITY

DEMO

create branchcreate and checkout branchdetached head

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

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

MERGE

fast­forwardsharing same ancestor lineage

recursive ­ non fast­forwarddifferent merge base

FAST FORWARD MERGE 1/3

FAST FORWARD MERGE 2/3

FAST FORWARD MERGE FINAL

RECURSIVE MERGE 1/2

RECURSIVE MERGE FINAL

DEMO

fast­forward mergerecursive merge

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

RECURSIVE MERGE

Duration: 3 minutes

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

CAVEAT OF GIT

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

TOOLS USED IN THIS PRESENTATION

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

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


Recommended