37
Git Makes Me Angry Inside Emma Jane Westby Education Development Coordinator Drupalize.Me @emmajanehw http://drupalize.me Slides at: http://tinyurl.com/dcto13-git Saturday, 13 July, 13 Problem: Developers face a steep learning curve when they choose to adopt version control. Solution: There is a version control strategy to suit your workflow, even if you've always thought it was too hard to bother. Is your project folder filled with files like this: page.old.2.bak.php? Does Git make you angry inside? Do you resent that everyone except you regularly visits the magical place referred to as "The Command Line"? Are you afraid of the vagrant who stole your puppet? In this session you will get a gentle introduction to working eciently as a developer in small teams, or as a solo developer. We'll focus on real world examples you can actually use to make your work faster and more ecient. Yes, this is an introductory session. This is for people who feel shame that they don't know how to "just cd into yer root durrr" and get mad when people say "just dime a patch" as if it's something as easy as making a mai thai even though you have no rum. No, you don't have to have git installed to attend. You don't even need to know where the command line is on your computer.

Git Makes Me Angry Inside

Embed Size (px)

Citation preview

Page 1: Git Makes Me Angry Inside

Git Makes Me Angry Inside

Emma Jane WestbyEducation Development CoordinatorDrupalize.Me

@emmajanehwhttp://drupalize.me

Slides at: http://tinyurl.com/dcto13-git

Saturday, 13 July, 13

Problem: Developers face a steep learning curve when they choose to adopt version control.Solution: There is a version control strategy to suit your workflow, even if you've always thought it was too hard to bother.Is your project folder filled with files like this: page.old.2.bak.php? Does Git make you angry inside? Do you resent that everyone except you regularly visits the magical place referred to as "The Command Line"? Are you afraid of the vagrant who stole your puppet? In this session you will get a gentle introduction to working efficiently as a developer in small teams, or as a solo developer. We'll focus on real world examples you can actually use to make your work faster and more efficient.Yes, this is an introductory session. This is for people who feel shame that they don't know how to "just cd into yer root durrr" and get mad when people say "just diff me a patch" as if it's something as easy as making a mai thai even though you have no rum. No, you don't have to have git installed to attend. You don't even need to know where the command line is on your computer.

Page 2: Git Makes Me Angry Inside

Why Stick Around

• Learn how Git thinks, without being exposed to the command line.

• Learn how to structure your work flow to take advantage of Git.

• Learn how basic commands are applied to common work flow scenarios.

• Q&A / therapy session

Saturday, 13 July, 13

Page 3: Git Makes Me Angry Inside

What’s your role?

Saturday, 13 July, 13

You need to start with the people....

Page 4: Git Makes Me Angry Inside

What are your tasks?

download work

create snapshot

share work

Saturday, 13 July, 13

What are the tasks that your team work on?For example: download work, make changes, upload work to a shared space.

Page 5: Git Makes Me Angry Inside

What’s your workflow?

Saturday, 13 July, 13

There are a lot of valid workflows.

Page 6: Git Makes Me Angry Inside

What’s your branch management strategy?

Saturday, 13 July, 13

As your people are working together, they need to have private, and shared spaces to do their work. This is where a branch management strategy gets layered in.

Page 7: Git Makes Me Angry Inside

How do we make Git do that?

Git Shell, cross-platform

Saturday, 13 July, 13

We’re not going to talk about the specifics of how to run commands today. But these are a few examples of the GUIs that are available for different platforms. (You don’t *have to be* stuck on the command line if you don’t want to be.)

Before we get started: let’s take a second to find out who you are. Why are you here, and how are you currently struggling with version control?

Page 8: Git Makes Me Angry Inside

Git is 90% process and 10% technology.

• Git was written by kernel developers, for kernel developers. Chances are high you’re not a kernel developer. Stop blaming yourself, and start blaming Git for your struggles.

• Not all is lost! If you can diagram the problem you are trying to solve; you will be able to find the right Git commands.

• Before we start drawing pictures, let’s take a look at some of the concepts version control helps us with.

Saturday, 13 July, 13

Out of the box, Git does basically nothing for you. It’s your processes that will allow you to apply the tools you need to make version control work for you.

Then go through each of the points listed.

Transition: let’s take a look at some of the terms you’ll run into when working with Git to give us a shared language.

Page 9: Git Makes Me Angry Inside

Version control (sort of) makes automation easier

• Backup and restore

• Synchronize across multiple platforms

• Short-term “undo” to test implications of changes

• Long-term “undo” to reverse bugs or regressions

• Track changes to see why/how software evolved

• Track ownership to give “credit” to change makers

• Sandbox code to test changes without affecting other people and systems

Saturday, 13 July, 13

There are a lot of valid reasons to use version control. The biggest gain bigger teams will see is in automation of process. But you don’t need to automate things to take advantage of version control.

Read through the list of things version control helps with.

Page 10: Git Makes Me Angry Inside

Terminology: locations

• remote repository

• trunk or main

• head or tip

• local repository

• client

• working copy

Saturday, 13 July, 13

There are a lot of terms in version control. Creating a map of where things live can make the documentation a lot easier to deal with.

Repo: database of changes to your files.Server: computer storing the repoClient: computer connecting to the repoWorking copy: local copy where changes are madeTrunk/main: The current, primary source for unchanged codeHead: the latest revision in a repository (tip: latest in a branch...HEAD moves, tip doesn’t).

Page 11: Git Makes Me Angry Inside

Terminology: actions and tasks

Saturday, 13 July, 13

With our locations mapped out, let’s take a look at the common tasks or “actions” you can take.

Basic actions:adopt / download: clone, merge, fetch, checkout, pull/rebasereview: log, statuscompare: diff HEAD, diff, diff --cachedreset: checkout, checkout HEAD, reset --hard (throw away in-between commits), revert (save in-between commits)save: add -u, commit, commit -adistribute: push

Page 12: Git Makes Me Angry Inside

Set the stage!

Before we can set our workflow we need to know who we’re dealing with and what they’re supposed to be doing.

Saturday, 13 July, 13

People first. In this next section, we’ll start with the folks on your team (not the software).

Page 13: Git Makes Me Angry Inside

Who’s on your code team?

Write down a list of all of the people on your code team. This list may include:

• developers

• designers

• project managers

• clients

Saturday, 13 July, 13

Who are the folks on your team? Designer? Developer? Site builder?

Page 14: Git Makes Me Angry Inside

Where do you fit in?

Maybe you do everything. Maybe you only do some things. Write a list of all the tasks you are actually responsible for. This might include:

• Writing code.

• Reviewing code.

• Pushing tested code to the server.

• Fixing broken code.

Saturday, 13 July, 13

Slide is “as advertised”.

Page 15: Git Makes Me Angry Inside

What are your tools and restraints?

Often there are other things we need to fit into our workflow. Create a third list of any tools and restraints you are aware of. This list might include:

• Version control software (we’ll always assume Git)

• Code hosting system (Bitbucket, GitHub, self-hosted)

• Server ecosystem (dev / staging / live)

• Code editors & integrated developer environments (vim, Dreamweaver, Sublime, PHPstorm)

• Automated testing systems or review “gates”

Saturday, 13 July, 13

Slide is “as advertised”.

Page 16: Git Makes Me Angry Inside

What’s your workflow?

With the team members identified, it’s time to sketch out how these people (ideally) work together.

Saturday, 13 July, 13

Now that we know the people, let’s talk about how they work together. There are lots of valid ways of working together, let’s take a look at a few of them.

Page 17: Git Makes Me Angry Inside

Solo developer workflow

Saturday, 13 July, 13

Solo dev workflow: create project, add files, do work, upload files

Page 18: Git Makes Me Angry Inside

Partner workflow with no central server

Saturday, 13 July, 13

James starts a grocery list; Emma already had a grocery list started so she asks to see James’s list. She adds her items to James’s list and hands it back.

Page 19: Git Makes Me Angry Inside

Centralized workflow with no local commits

Saturday, 13 July, 13

the “old” style of version control has a single place where all work is checked into. Every time work is saved, it’s uploaded to the shared space. You can implement this workflow with distributed version control too, but you wouldn’t want to.

Page 20: Git Makes Me Angry Inside

Decentralized with human gatekeeper

Saturday, 13 July, 13

This is pretty typical: it’s a decentralized workflow. The developers pull/clone. Do their work locally and then ask their “gatekeeper” to check their work and merge it into the central repo. Once the central repo has the changes, the devs grab a fresh copy and continue their work.

Page 21: Git Makes Me Angry Inside

Decentralized with automated gatekeeper

Saturday, 13 July, 13

The decentralized with automated gatekeeper is almost the same, except it’s a computer making the decision on whether or not code should be accepted. This is fine for quantitative reviews, but shouldn’t be used for qualitative reviews...unless there are pre-merge peer reviews also happening.

Page 22: Git Makes Me Angry Inside

Sketch out your workflow

• Identify the roles on your team.

• Identify the relationships between the team members.

• Draw arrows to show how code flows between team members.

Saturday, 13 July, 13

Slide is “as advertised”.

Page 23: Git Makes Me Angry Inside

How will you manage your branches?

With the workflow described, it’s time to look at how the code will be segregated into different branches.

Saturday, 13 July, 13

This is where the fun starts! Managing branches in a distributed workflow.

Page 24: Git Makes Me Angry Inside

Popular strategies

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

• http://scottchacon.com/2011/08/31/github-flow.html

Saturday, 13 July, 13

Page 25: Git Makes Me Angry Inside

Work flow and branch management

Saturday, 13 July, 13

Page 26: Git Makes Me Angry Inside

Work flow and branch management

Saturday, 13 July, 13

Page 27: Git Makes Me Angry Inside

Work flow and branch management

peer review

Saturday, 13 July, 13

Page 28: Git Makes Me Angry Inside

Work flow and branch management

peer review

public / live server

Saturday, 13 July, 13

Page 29: Git Makes Me Angry Inside

Work flow and branch management

peer review

public / live server

Saturday, 13 July, 13

Page 30: Git Makes Me Angry Inside

Work flow and branch management

peer review

public / live server

dev / testing server

Saturday, 13 July, 13

Page 31: Git Makes Me Angry Inside

Work flow and branch management

peer review

public / live server

dev / testing server

master

master

master

Saturday, 13 July, 13

Page 32: Git Makes Me Angry Inside

Work flow and branch management

peer review

public / live server

dev / testing server

master

master

master

dev

dev

dev

Saturday, 13 July, 13

Page 33: Git Makes Me Angry Inside

Work flow and branch management

feature feature

hotfix feature

peer review

public / live server

dev / testing server

master

master

master

dev

dev

dev

Saturday, 13 July, 13

Page 34: Git Makes Me Angry Inside

Work flow and branch management

feature feature

hotfix feature

peer review

public / live server

dev / testing server

master

master

master

dev

dev

dev

Saturday, 13 July, 13

Page 35: Git Makes Me Angry Inside

Sketch out your branch management strategy

• Identify the roles on your team.

• Identify the relationships between the team members.

• Draw arrows to show how code flows between team members.

• Time: 10 minutes

Saturday, 13 July, 13

Page 36: Git Makes Me Angry Inside

Q&A + Git Therapy Session

Saturday, 13 July, 13

Page 37: Git Makes Me Angry Inside

You can make Git do what you want...now that you know what you want.

@emmajanehwhttp://drupalize.me

Slides: http://lb.com/dcto13-gitHow to git: http://lb.cm/howto-git-videos

Saturday, 13 July, 13