Slide 1

Slide 1 text

git init Initialise Your Git Skills for Drupal

Slide 2

Slide 2 text

Topics Covered  What is Git?  Creating a Repository  Git Commands  Applying a Patch from Drupal.org  Creating a Patch for Drupal.org

Slide 3

Slide 3 text

What is Git?  Version Control System (VCS)  Track changes to a set of files over time  Many file types – txt, php, jpg etc  Developed by Linus Torvalds  Used by Drupal to manage core/contrib https://github.com/git/git

Slide 4

Slide 4 text

Git is Similar to Computer Games?

Slide 5

Slide 5 text

Saved Games

Slide 6

Slide 6 text

Git Commands

Slide 7

Slide 7 text

Creating a Repository I git init Initialises a new Git repository

Slide 8

Slide 8 text

Creating a Repository II git clone

Slide 9

Slide 9 text

Git Workflow Source: https://www.atlassian.com/git/tutorial/git-basics#!add

Slide 10

Slide 10 text

Adding Files to Staging Area git add git add git add git add .

Slide 11

Slide 11 text

Saving State git commit git commit –m “Commit message”

Slide 12

Slide 12 text

What’s Goin’ on? git status List which files have been modified or are untracked

Slide 13

Slide 13 text

Viewing Commit History git log Displays committed snapshot history

Slide 14

Slide 14 text

status vs log Source: https://www.atlassian.com/git/tutorial/git-basics#!log

Slide 15

Slide 15 text

Check it Out git checkout git checkout git checkout git checkout

Slide 16

Slide 16 text

Demo Source: http://www.redbubble.com/people/littleredplanet/works/6426341-show-me-the-code?p=sticker

Slide 17

Slide 17 text

What’s Changed? git diff Display all changes in the working directory Similar to git status

Slide 18

Slide 18 text

Patching Drupal What is a Patch?

Slide 19

Slide 19 text

Patch Anatomy Command used to create the file Affected Files Hunks of Changes

Slide 20

Slide 20 text

Patching Drupal Why Patch?  Fix a bug  Add functionality How to Patch?  Manually  With Git

Slide 21

Slide 21 text

Applying Drupal Patches - Manually  Manually add changes to the code files  Look for RTBC or confirmation from other Drupalers  Apply patch in dev first!

Slide 22

Slide 22 text

Demo – Manual Patch Feeds module – unique GUID https://drupal.org/node/1539224#comment-7394766 Image source: http://fourkitchens.com/blog/2011/08/22/apply-patch-clear-cache

Slide 23

Slide 23 text

Applying Drupal Patches – with Git  Instructions are on the project page  Clone project with Git  Download patch to module/theme directory  git apply -v [patchname.patch]

Slide 24

Slide 24 text

Demo – Patch with Git Waitlist message – entity registration module https://drupal.org/node/2018741#comment-7754431 Image source: http://fourkitchens.com/blog/2011/08/22/apply-patch-clear-cache

Slide 25

Slide 25 text

Creating Drupal Patches 1. Search issue queue first 2. Newest version of project where bug exists? 3. Clone code from drupal.org 4. Create the patch  Coding and security standards  Make changes  Test changes  Name patch: [issue_name]-[short-description]- [issue-number]-[comment-number].patch  Submit to issue queue

Slide 26

Slide 26 text

Demo – Creating a Patch  Instructions are on the project page

Slide 27

Slide 27 text

We created a patch!

Slide 28

Slide 28 text

Further Reading Git  http://git-scm.com/  http://gitref.org/  Install git - http://git-scm.com/book/en/Getting- Started-Installing-Git Drupal Patches  http://drupalladder.org/lesson/72a836e6-b408- a7a4-1923-8788761b2608  http://jacine.net/post/8419331209/patches  https://drupal.org/patch/submit