git training: a basic tutorial

38
Andrew Turner [Sq1 Agency], http://sq1agency.com version control

Upload: andrew-turner

Post on 21-Feb-2016

252 views

Category:

Documents


0 download

DESCRIPTION

A deck used to train first-time git users.

TRANSCRIPT

Page 1: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

version control

Page 2: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

SECTIONS

Page 3: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

SECTIONS

•what?

•why?

•how?

•workflow

•demo

•setup [hands-on]

Page 4: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHAT?

Page 5: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHAT IS VERSION CONTROL?

“Version control is a system that records changes to a

file or set of files over time so that you can recall

specific versions later.”

- Pro Git [progit.org]

Page 6: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHAT IS VERSION CONTROL?

# Version Control allows us to easily...•revert files to a previous state

•revert project to a previous state

•compare changes between file versions

•see who last modified a file

•recover when things go wrong

Page 7: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHAT? : TYPES

•Local •Centralized Version Control System (CVCS)•Distributed Version Control System (DVCS)

Page 8: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

TYPES : LOCAL

•a method of manually duplicating and renaming files•how most people keep backups (versions) of their work

# Advantages•simple•no setup / training

# Disadvantages•error prone / easily messy•single point of failure

# Examples•Local Hard Drive

Page 9: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

TYPES : CENTRALIZED

•a client-server approach•a single server that contains all the versioned files•a number of clients that check out files from the server

# Advantages•good for collaborative development•everyone works on the same files

# Disadvantages•single point of failure•always-on internet connection / slow server = slow work

# Examples•Subversion (SVN)

Page 10: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

TYPES : CENTRALIZED

Page 11: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

TYPES : DISTRIBUTED

•a peer-to-peer approach•each peer has a complete working copy and history of project

# Advantages•great for collaborative development•multiple backups of project•no internet (work done locally then pushed to server)•can be used for more than just code (Photoshop files too!!)

# Disadvantages•more complex / setup and training

# Examples•Git, Mercurial

Page 12: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

TYPES : DISTRIBUTED

Page 13: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHAT IS GIT?

“Git is distributed version control system focused on

speed, effectivity and real-world usability on large

[and small] projects.”

- Git [git-scm.com/about]

Page 14: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHY?

Page 15: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHY USE VERSION CONTROL?

“If you’ve ever made a mistake then you need to use

version control...”

- multiple blogs

Page 16: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WHY USE VERSION CONTROL?

# Benefits of using a VCS•encourages better organization

•enables better collaborative work

•maintains a detailed history of a project

•easily recover from failures / errors

•easier to try experimental code with a project

•...so many more reasons!

Page 17: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW?

Page 18: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW TO USE GIT?

•concepts

•terminology

•basics

•commands

•remotes

Page 19: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW? : CONCEPTS

# Local•installed on your local machine and run from command line•full repository and history on local machine•used in conjunction with preferred editors / IDE (Dreamweaver)

# Integrity•project integrity (snapshots, not differences)•data integrity (checksums)

# Additions Only•git generally only adds data (that is committed)•freedom to experiment without loss

Page 20: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW? : TERMINOLOGY

# Repository (repo)•[n] the .git directory that stores all version control information, history, and files

# Commit•[n] a single point in the git history•[v] the act of storing a project’s current state in the repo

# HEAD•[n] pointer to the most recent commit

Page 21: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW? : BASICS

# Working Directory•new/edited files

# Staging Area (INDEX)•files ready to commit

# Repository•committed snapshots•history of commits and branches

Page 22: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW? : COMMANDS

•init - creates a new git repository•add - stages either a new or edited file to the INDEX•commit - stores a snapshot of project’s current state•status - shows any changes to the working directory•pull - fetches and merges from a remote repo•push - updates a remote repo with local changes

Page 23: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

HOW? : REMOTES

# GitHub•hosted git repos•built for collaborative development•“central” collaborative point•ensured backup of code•ability to deploy locally from remote repo to multiple servers [dev, live, staging, etc]

•integrated issue tracking•web-based editor for quick-fixes

Page 24: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

Page 25: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Create New Repository•git init

Page 26: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Start Project Development•no git action

Page 27: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Stage file•git add

Page 28: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Commit Changes and Save Status•git commit

Page 29: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Continue Project Development•no git action

Page 30: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Stage Changed File•git add

Page 31: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

WORKFLOW

# Commit Changes and Save Status•git commit

Page 32: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

DEMO

Page 33: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

SETUP

Page 34: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

SETUP : LET’S GIT STARTED

# Create GitHub Account•Sign up for FREE GitHub account [github.com]•Add SSH Key to GitHub []

# Install Git on Computer•Mac [code.google.com/p/git-osx-installer]•Windows [code.google.com/p/msysgit]

# Install GUI for Development•Mac [mac.github.com]•Windows [code.google.com/p/msysgit]

Page 35: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

RESOURCES

Page 36: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

RESOURCES

# General Links•Official Git Website [git-scm.com]•GitHub [github.com]•Sq1 GitHub Profile [github.com/sq1agency]

# References•GitHub Help Docs [help.github.com]•Git Reference [gitref.org]•Git Glossary [goo.gl/j1kck]•Git Cheat Sheets [help.github.com/git-cheat-sheets]

Page 37: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

RESOURCES

# Books•Pro Git Digital Book [progit.org]•Git Community Book [book.git-scm.com]

# Tutorials•Git Immersion Tutorial [gitimmersion.com]•GitCasts: Screencasts [gitcasts.com]•Git For Beginners [ryanflorence.com/git-for-beginners]•Illustrated Guide to Git on Windows [nathanj.github.com/gitguide/tour.html]

•Git and GitHub on Windows [kylecordes.com/2008/git-windows-go]

Page 38: Git Training: A basic tutorial

Andrew Turner [Sq1 Agency], http://sq1agency.com

RESOURCES

# GUI Applications - Mac•GitHub Mac [mac.github.com]•Tower [git-tower.com]•GitX [gitx.frim.nl]•GitBox [gitboxapp.com] (also in Mac App Store)

# GUI Applications - Windows•TortoiseGit [code.google.com/p/tortoisegit]•Git Extensions [code.google.com/p/gitextensions]•SmartGit [syntevo.com/smartgit]