Slide 1

Slide 1 text

Git Intro Workshop 2015-10-24 (Sat) Southern University College Huiming 
 [email protected] twitter.com/teohm github.com/teohm VJKUUNKFGKUCXCKNCDNGJGTG speakerdeck.com/teohm

Slide 2

Slide 2 text

Done? Install Github Desktop (Windows) Sign-up GitHub (Free Account) Step-by-Step Guide: bit.ly/github-install

Slide 3

Slide 3 text

Schedule Part 1 (10am - 12noon) • What is Version Control? • Git Basic ———— Lunch ————— Part 2 (1pm - 3pm) • Git Remote & GitHub • GitHub Free Web Hosting

Slide 4

Slide 4 text

Part 1

Slide 5

Slide 5 text

Version Control • Version Control System (VCS) — track changes to a set of contents over time so that you can go back to a specific version later. • Survey — What VCS do you use?

Slide 6

Slide 6 text

copy-paste VCS

Slide 7

Slide 7 text

.bk VCS

Slide 8

Slide 8 text

.bk VCS

Slide 9

Slide 9 text

Version Control Different ways to access history & content • Local - rcs, (your copy-paste vcs) • Centralized - cvs, subversion, … • Decentralized - bitkeeper, git, mercurial, …

Slide 10

Slide 10 text

Version Control Different ways to track change history • Linear - subversion
 
 • Directed acyclic graph (DAG) - git r1 r2 r3

Slide 11

Slide 11 text

Version Control Different ways to store content • Delta (diff)-based 
 - mercurial, 
 subversion
 • Snapshot-based 
 - git,
 (your copy-paste vcs)

Slide 12

Slide 12 text

Git Decentralized, DAG Graph History, Snapshot-Based

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

I can use Git to … • Record code changes • Go back to a previous version • Switch between multiple work • Backup to cloud • Upload to web hosting • Merge codes from team members

Slide 15

Slide 15 text

I can use Git to … • Record code changes • Go back to a previous version • Switch between multiple work • Backup to cloud • Upload to web hosting • Merge codes from team members Part 1 Part 2

Slide 16

Slide 16 text

Record changes • Setup new repository • Add new file, modify file, delete file • Commit the changes 
 git init
 git status
 git add .
 git add index.html
 git add -p
 git commit
 git commit -m 'one-line summary'
 git rm old.html


Slide 17

Slide 17 text

Prepare a commit working folder stage
 (index) commit git add git commit

Slide 18

Slide 18 text

Go back in time • Go back to a previous commit • Bring a back deleted file • Reverse a wrong commit 
 git log git log --graph --oneline git show 98ca3
 git checkout 98ca3
 git checkout 98ca3 index.html
 git revert 98ca3


Slide 19

Slide 19 text

Switch between work • Half-way working on a big feature • And boss asks you fix a urgent bug NOW! • Handle merge conflicts 
 git branch big_feature git checkout big_feature git checkout master
 git checkout -b bug_fix
 git merge bug_fix
 git merge big_feature git stash


Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

Part 2

Slide 22

Slide 22 text

Git Alias • Add shortcut commands to Git e.g. 
 git status -> git st
 git commit -> git ci • Edit /Users/username/.gitconfig [alias]
 co = checkout
 ci = commit
 st = status
 br = branch
 lg = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short 


Slide 23

Slide 23 text

Backup to GitHub • Push codes to a remote Git hosting service 
 git remote add origin url git push -u origin master

Slide 24

Slide 24 text

Deploy to GitHub Pages • Deploy to GitHub free website hosting • Your personal website URL — username.github.io 
 pages.github.com

Slide 25

Slide 25 text

Next Step? • Learn by start using! • Books • Pro Git, Scott Chacon — progit.org • Pro Git 中⽂文版 — iissnan.com/progit/ • Talks • Introduction to Git with Scott Chacon of GitHub (YouTube) • More materials • git-scm.com/doc/ext

Slide 26

Slide 26 text

Feedback bit.ly/git-workshop-survey Wish to join more workshops?