58
Nathaniel Schweinberg @nathanielks FightTheCurrent.org

What the Git? - WordCamp Atlanta

Embed Size (px)

Citation preview

Page 1: What the Git? - WordCamp Atlanta

Nathaniel Schweinberg @nathanielks

FightTheCurrent.org

Page 2: What the Git? - WordCamp Atlanta

What the git?

Page 3: What the Git? - WordCamp Atlanta

It keeps track of your code!

git is a Source Control Management application

Page 4: What the Git? - WordCamp Atlanta
Page 5: What the Git? - WordCamp Atlanta

git stores only the changes you make

Page 6: What the Git? - WordCamp Atlanta
Page 7: What the Git? - WordCamp Atlanta

git allows you to focus on the feature you’re

writing

Page 8: What the Git? - WordCamp Atlanta

http://hades.name/blog/2010/01/22/git-your-friend-not-foe-vol-2-branches/

Page 9: What the Git? - WordCamp Atlanta

git allows multiple developers to work on the same project

Page 10: What the Git? - WordCamp Atlanta

http://git-scm.com/about/distributed

Page 11: What the Git? - WordCamp Atlanta

How to get started!

Page 12: What the Git? - WordCamp Atlanta

Step 1: Install git

http://git-scm.com/book/en/Getting-Started-Installing-Git

Page 13: What the Git? - WordCamp Atlanta

Step 2: OPEN TERMINAL

Page 14: What the Git? - WordCamp Atlanta
Page 15: What the Git? - WordCamp Atlanta

Step 3: Get it set up

http://git-scm.com/book/en/Getting-Started-First-Time-Git-Setup

Page 16: What the Git? - WordCamp Atlanta
Page 17: What the Git? - WordCamp Atlanta
Page 18: What the Git? - WordCamp Atlanta

How git works

http://git-scm.com/about/staging-area

Page 19: What the Git? - WordCamp Atlanta

Initializes a git repository in current folder

git init

Page 20: What the Git? - WordCamp Atlanta

Adds file . to the staging area ( . means current folder and all files inside )

git add .

Page 21: What the Git? - WordCamp Atlanta

Commits files added to staging area ( -m adds commit message )

git commit –m ‘initial commit’

Page 22: What the Git? - WordCamp Atlanta
Page 23: What the Git? - WordCamp Atlanta

Shows current status of working directory

git status

Page 24: What the Git? - WordCamp Atlanta

http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository

Page 25: What the Git? - WordCamp Atlanta
Page 26: What the Git? - WordCamp Atlanta

BRANCHING

Page 27: What the Git? - WordCamp Atlanta

Branching encourages a few things

Frictionless Context Switching Feature Based Workflow

Disposable Experimentation

http://git-scm.com/about

Page 28: What the Git? - WordCamp Atlanta
Page 29: What the Git? - WordCamp Atlanta

Create new branch to work from

git branch name

Page 30: What the Git? - WordCamp Atlanta

Sets working tree to branchname

git checkout branchname

Page 31: What the Git? - WordCamp Atlanta
Page 32: What the Git? - WordCamp Atlanta

Create and checkout into branchname

git checkout –b branchname

Page 33: What the Git? - WordCamp Atlanta
Page 34: What the Git? - WordCamp Atlanta
Page 35: What the Git? - WordCamp Atlanta

Merges committed changes made in branchname with current branch

git merge branchname

Page 36: What the Git? - WordCamp Atlanta

Repositories!

Page 37: What the Git? - WordCamp Atlanta
Page 38: What the Git? - WordCamp Atlanta

Let’s add a remote repository

Page 39: What the Git? - WordCamp Atlanta
Page 40: What the Git? - WordCamp Atlanta

Two basic actions

git push Pushes changes to

remote repo

git pull Pulls changes from

remote repo

Page 41: What the Git? - WordCamp Atlanta

Let’s integrate with WordPress!

Page 42: What the Git? - WordCamp Atlanta
Page 43: What the Git? - WordCamp Atlanta

Use git clone to duplicate a remote repository locally

git clone

Page 44: What the Git? - WordCamp Atlanta
Page 45: What the Git? - WordCamp Atlanta

Submodules allow you to keep separate sections of your code under source control

( repos within repos )

Submodules!

Page 46: What the Git? - WordCamp Atlanta

Adds submodule located at repository to path/to/location within project

git submodule add repository

path/to/location

Page 47: What the Git? - WordCamp Atlanta
Page 48: What the Git? - WordCamp Atlanta

Use .gitignore to prevent files from being added to the repo

.gitignore

Page 49: What the Git? - WordCamp Atlanta
Page 50: What the Git? - WordCamp Atlanta

Let’s Talk strategy

Page 51: What the Git? - WordCamp Atlanta

Commit early, Commit Often

Page 52: What the Git? - WordCamp Atlanta

Use descriptive commit messages!

Page 53: What the Git? - WordCamp Atlanta

Always develop on a separate branch

Master branch is stable ONLY.

Page 54: What the Git? - WordCamp Atlanta

ns/some-cool-feature

Branch naming: initials/feature-name

Page 55: What the Git? - WordCamp Atlanta

Working with multiple Devs

Page 56: What the Git? - WordCamp Atlanta

Updates current branch with changes made in another

git rebase branchname

Page 57: What the Git? - WordCamp Atlanta

http://bit.ly/WhatTheGit

Resources:

Page 58: What the Git? - WordCamp Atlanta

Nathaniel Schweinberg @nathanielks

FightTheCurrent.org