Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

43
Open Innovation Lab (OIL) GIT Intro Workshop PantaRei Design Limited Wong Hoi Sing, Edison 2015 Feb 27th

Transcript of Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Page 1: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Open Innovation Lab (OIL)

GIT Intro Workshop

PantaRei Design LimitedWong Hoi Sing, Edison

2015 Feb 27th

Page 2: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Wong Hoi Sing, Edison

● CEO, Founder, PantaRei Design– 2009, PantaRei Design founded

– 2010, HKFYG YBHK applicant

– 2011, ITF SERAP applicant

– 2011, HKSTP Incu-Tech applicant

● FOSS and Drupal Developer, Contributor and HKDUG Co-founder– 2000, Debian GNU/Linux 2.2 ('potato')

– 2005, Drupal Developer

– 2008, BarCamp HK Speaker

– 2008, HKDUG Co-founder

– 2011, Drupal 7.x Core Contributor

[email protected]● https://www.drupal.org/u/hswong3i

Page 3: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

PantaRei Design

● Hong Kong based FOSS service provider– Content Management System (CMS) with Drupal

– Cloud Hosting Solution with Amazon Web Services (AWS)

● Business Partner with industry leaders– 2012, AWS Consulting Partner

– 2013, Acquia Partner

– 2013, Atlassian Experts

– 2014, Rackspace Hosting Partner

Page 4: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 5: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 6: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 7: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 8: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 9: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 10: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Outline

● What is GIT?● Why GIT?● 15mins Tutorial● Advanced Topic(s)

Page 11: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

What is GIT?

● Distributed revision control and source code management (SCM) system

● Designed to handle everything from small to very large projects

● Designed and developed by Linus Torvalds for Linux kernel development in 2005

Page 12: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 13: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Why GIT?

● Manage code changes by rename file will soon reach its limitation, e.g.– mycode-20140308.php

– mycode-201403080930.php

● Archive entire folder will make case even worse– Need to extract before compare the changes

● Share progress with co-workers become nightmare

Page 14: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Why GIT? (cont.)

● CVS– Manage revision per file (rename not support)

– Remote repository server required (no local folder offline management)

– Single commit management (other else contribute by submit patches)

– TOOOOO OLD (well...)● Used by Drupal during 7.x development cycle● After Drupal 7 released, soon migrated to GIT

Page 15: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Why GIT? (cont.)

● SVN– Manage revision per folder

– Remote repository server required

– Single commit management

– A bit better than CVS, but branching model still looks crazy

● At least, we now have GIT, why still using SVN?

Page 16: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Why GIT? (cont.)

● GIT– Manage revision per entire project

– Remote/local repository supported● git init● git add --all .● git commit -am 'Initial commit'● git log● git status

– Distributed workflows

– Used by https://drupal.org/ since Drupal 7

– You also know https://github.com/, isn't it?

Page 17: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 18: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

15mins Tutorial

● Installation– Debian/Ubuntu

● apt-get install git git-flow

– Mac● brew install git git-flow

– Windows● https://msysgit.github.io/

Page 19: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

15mins Tutorial (cont.)

● Basic commands– git init

– git status

– git add

– git rm

– git commit

– git log

Page 20: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

15mins Tutorial (cont.)

● Remote commands– git remote

– git push

– git pull

Page 21: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

15mins Tutorial (cont.)

● Advanced commands– git diff

– git reset

– git checkout

– git branch

– git merge

Page 23: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Advanced Topic(s)

● Gitflow Workflow● Continuous Integration (CI)● Migrate to GIT from SVN● Dropbox-like File Sharing

Page 24: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Gitflow Workflow

● The Gitflow Workflow defines a strict branching model designed around the project release

● Developers work locally and push branches to the central repo

● The only difference is the branch structure of the project

Page 29: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Continuous Integration (CI)

● Test-Driven Development (TDD) or Behavior-Driven Development (BDD)

● Combination with automated unit tests, e.g. running phpunit per each GIT commit– GitHub → Travis CI

– Stash → Bamboo

Page 33: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Migrate to GIT from SVN

● Prepare your environment for the migration.● Convert the SVN repository to a local GIT repository.● Synchronize the local GIT repository when the SVN

repository changes.● Share the GIT repository with your developers via

Bitbucket.● Migrate your development efforts from SVN to GIT.

Page 35: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Dropbox-like File Sharing

● Dropbox– Public cloud-based file hosting service

● GIT– Repository management with history

● SparkleShare– GIT-based file hosting solution with history

– Just manage share and permission as normal GIT repository

– Support public (e.g. GitHub, BitBucket) or private (e.g. Stash, GitLab) GIT repository

– Suitable for small size file sharing

– Dropbox-like operation, NO GIT command is required!!

Page 37: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 38: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Dropbox-like File Sharing (cont.)

● BitTorrent Sync– Peer-to-peer file synchronization

– Over the Internet via secure, distributed P2P technology

● Unlike GIT-based solution:– Suitable for large-size binary file hosting

– No complete history support

● How we use SparkleShare and BitTorrent Sync?– BitTorrent Sync: Short-term working copy sharing

– SparkleShare: Long-lasting archive with history

Page 40: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Page 41: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Q&A

Page 42: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

References

● http://git-scm.com/

● https://try.github.io/levels/1/challenges/1

● http://www.slideshare.net/svenpeters/getting-git-right

● https://www.atlassian.com/git/tutorials

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

● https://github.com/nvie/gitflow

● https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

● http://danielkummer.github.io/git-flow-cheatsheet/

● http://www.webupd8.org/2011/03/set-up-sparkleshare-with-your-own.html

● http://www.webupd8.org/2014/03/install-bittorrent-sync-gui-in-ubuntu.html

Page 43: Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop

Thank You

● Please feel free to contact us:– PantaRei Design Limited– Unit 326, 3/F, Building 16W

No.16 Science Park West AvenueHong Kong Science Park, Shatin, N.T.

– Phone: +852 2576 3812

– Fax: +852 3753 3663– Email: [email protected]– Web: http://pantarei-design.com