Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git Intro Workshop - SUC (2015-10-24)

Git Intro Workshop - SUC (2015-10-24)

Huiming Teo

October 24, 2015
Tweet

More Decks by Huiming Teo

Other Decks in Technology

Transcript

  1. Git Intro Workshop 2015-10-24 (Sat) Southern University College Huiming 


    [email protected] twitter.com/teohm github.com/teohm VJKUUNKFGKUCXCKNCDNGJGTG speakerdeck.com/teohm
  2. Schedule Part 1 (10am - 12noon) • What is Version

    Control? • Git Basic ———— Lunch ————— Part 2 (1pm - 3pm) • Git Remote & GitHub • GitHub Free Web Hosting
  3. 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?
  4. Version Control Different ways to access history & content •

    Local - rcs, (your copy-paste vcs) • Centralized - cvs, subversion, … • Decentralized - bitkeeper, git, mercurial, …
  5. Version Control Different ways to track change history • Linear

    - subversion
 
 • Directed acyclic graph (DAG) - git r1 r2 r3
  6. Version Control Different ways to store content • Delta (diff)-based

    
 - mercurial, 
 subversion
 • Snapshot-based 
 - git,
 (your copy-paste vcs)
  7. 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
  8. 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
  9. 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

  10. 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

  11. 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

  12. 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 

  13. Backup to GitHub • Push codes to a remote Git

    hosting service 
 git remote add origin url git push -u origin master
  14. Deploy to GitHub Pages • Deploy to GitHub free website

    hosting • Your personal website URL — username.github.io 
 pages.github.com
  15. 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