Slide 1

Slide 1 text

+ = awesome Ryan McCue @rmccue

Slide 2

Slide 2 text

three sections

Slide 3

Slide 3 text

1) git basics 2) efficient git 3) git + WordPress

Slide 4

Slide 4 text

1) git basics 2) efficient git 3) git + WordPress + WordPress community summit

Slide 5

Slide 5 text

command line?

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

I am going to lie to you Warning:

Slide 9

Slide 9 text

this might hurt your head Warning:

Slide 10

Slide 10 text

this might hurt your head Warning: let me know!

Slide 11

Slide 11 text

1) git basics 2) efficient git 3) git + WordPress

Slide 12

Slide 12 text

what is git?

Slide 13

Slide 13 text

git manages history

Slide 14

Slide 14 text

git manages history your files

Slide 15

Slide 15 text

your files my-theme/ index.php style.css

Slide 16

Slide 16 text

your files my-theme/ index.php style.css style.css.old

Slide 17

Slide 17 text

your files my-theme/ index.php style.css style.css.old style.css.bak style.css.bak.bak style.css.whatdidido style.css.help style.css.helphelp.help style.css.nooooo

Slide 18

Slide 18 text

git!

Slide 19

Slide 19 text

your files my-theme/ index.php style.css

Slide 20

Slide 20 text

“working directory”

Slide 21

Slide 21 text

$ git init

Slide 22

Slide 22 text

working my-theme/ index.php style.css committed my-theme/

Slide 23

Slide 23 text

working my-theme/ index.php style.css committed my-theme/ ?

Slide 24

Slide 24 text

$ git commit -a

Slide 25

Slide 25 text

$ git commit -a I’ll come back to this

Slide 26

Slide 26 text

working my-theme/ index.php style.css committed my-theme/ index.php style.css commit -a

Slide 27

Slide 27 text

working my-theme/ index.php style.css committed my-theme/ index.php style.css commit -a ?

Slide 28

Slide 28 text

$ git checkout

Slide 29

Slide 29 text

working my-theme/ index.php style.css committed my-theme/ index.php style.css commit -a checkout

Slide 30

Slide 30 text

edit part of the theme? what if I only

Slide 31

Slide 31 text

“staging area”

Slide 32

Slide 32 text

working committed staging my-theme/ my-theme/ my-theme/ index.php style.css ? ?

Slide 33

Slide 33 text

$ git add

Slide 34

Slide 34 text

$ git checkout

Slide 35

Slide 35 text

working committed staging my-theme/ index.php style.css my-theme/ my-theme/ index.php style.css add checkout

Slide 36

Slide 36 text

working committed staging my-theme/ index.php style.css my-theme/ my-theme/ index.php style.css add checkout ? ?

Slide 37

Slide 37 text

$ git commit

Slide 38

Slide 38 text

$ git reset

Slide 39

Slide 39 text

working committed staging my-theme/ index.php style.css my-theme/ index.php style.css my-theme/ index.php style.css add checkout commit reset

Slide 40

Slide 40 text

working committed staging my-theme/ index.php style.css my-theme/ index.php style.css my-theme/ index.php style.css add checkout commit reset commit -a reset --hard

Slide 41

Slide 41 text

$ git commit -a

Slide 42

Slide 42 text

$ cd mytheme/ $ git init Initialized empty Git repository in …/mytheme/.git/ $ vim index.php $ vim style.css $ git add index.php $ git add style.css $ git commit –m ‘Initial commit’ [master (root-commit) e6d6f02] Initial commit 0 files changed, 200 insertions(+), 0 deletions(-) create mode 100644 index.php create mode 100644 style.css

Slide 43

Slide 43 text

$ vim style.css $ git add style.css $ git commit –m ‘Improve styling for links’ [master dda31a3] Improve styling for links 1 files changed, 20 insertions(+), 2 deletions(-)

Slide 44

Slide 44 text

sharing is caring

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

your commits my-theme/ index.php style.css GitHub my-theme/ index.php style.css

Slide 47

Slide 47 text

your commits my-theme/ index.php style.css GitHub my-theme/ index.php style.css ? ?

Slide 48

Slide 48 text

$ git push -u origin master

Slide 49

Slide 49 text

$ git push -u origin master

Slide 50

Slide 50 text

$ git push -u origin master

Slide 51

Slide 51 text

$ git push

Slide 52

Slide 52 text

your commits my-theme/ index.php style.css GitHub my-theme/ index.php style.css push ?

Slide 53

Slide 53 text

$ git pull

Slide 54

Slide 54 text

your commits my-theme/ index.php style.css GitHub my-theme/ index.php style.css push pull

Slide 55

Slide 55 text

questions?

Slide 56

Slide 56 text

1) git basics 2) efficient git 3) git + WordPress

Slide 57

Slide 57 text

edit part of the theme? what if I only

Slide 58

Slide 58 text

edit part of the file? what if I only

Slide 59

Slide 59 text

$ git add -p

Slide 60

Slide 60 text

$ git add -p = awesome

Slide 61

Slide 61 text

$ git checkout -p add reset

Slide 62

Slide 62 text

$ vim style.css $ git add style.css $ git add -p

Slide 63

Slide 63 text

$ git add -p diff --git a/wp-admin/includes/class-wp-upgrader.php b/wp-admin/includes/class-wp-upgrader.php index ef8fb5f..f77c645 100644 --- a/wp-admin/includes/class-wp-upgrader.php +++ b/wp-admin/includes/class-wp-upgrader.php @@ -107,6 +107,10 @@ class WP_Upgrader { function download_package($package) { + $reply = apply_filters('upgrader_pre_download', false, $package, $this); + if ( false !== $reply ) + return $reply; + if ( ! preg_match('!^(http|https|ftp)://!i', $package) && file_exists($package) ) //Local file or remote? return $package; //must be a local file.. Stage this hunk [y,n,q,a,d,/,e,?]?

Slide 64

Slide 64 text

Stage this hunk [y,n,q,a,d,/,e,?]? ? y - stage this hunk n - do not stage this hunk q - quit; do not stage this hunk nor any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk nor any of the later hunks in the file g - select a hunk to go to / - search for a hunk matching the given regex j - leave this hunk undecided, see next undecided hunk J - leave this hunk undecided, see next hunk k - leave this hunk undecided, see previous undecided hunk K - leave this hunk undecided, see previous hunk s - split the current hunk into smaller hunks e - manually edit the current hunk ? - print help

Slide 65

Slide 65 text

branches

Slide 66

Slide 66 text

groups of changes

Slide 67

Slide 67 text

master

Slide 68

Slide 68 text

master my-theme/ index.php style.css new-stuff my-theme/ index.php style.css

Slide 69

Slide 69 text

master my-theme/ index.php style.css new-stuff my-theme/ index.php style.css ? ?

Slide 70

Slide 70 text

$ git branch $ git checkout

Slide 71

Slide 71 text

$ git checkout –b

Slide 72

Slide 72 text

$ git merge

Slide 73

Slide 73 text

master my-theme/ index.php style.css new-stuff my-theme/ index.php style.css branch merge

Slide 74

Slide 74 text

master new-stuff git checkout -b new-stuff

Slide 75

Slide 75 text

master new-stuff

Slide 76

Slide 76 text

master new-stuff git merge master

Slide 77

Slide 77 text

master new-stuff

Slide 78

Slide 78 text

master new-stuff git checkout master git merge new-stuff

Slide 79

Slide 79 text

push/pull

Slide 80

Slide 80 text

master new-stuff

Slide 81

Slide 81 text

master new-stuff GitHub you

Slide 82

Slide 82 text

$ git clone

Slide 83

Slide 83 text

$ git clone [email protected]:example/example.git

Slide 84

Slide 84 text

GitHub you me

Slide 85

Slide 85 text

GitHub you me

Slide 86

Slide 86 text

GitHub you me

Slide 87

Slide 87 text

$ git push To [email protected]:example/example.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:example/example.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes (e.g. 'git pull') before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details.

Slide 88

Slide 88 text

GitHub you me

Slide 89

Slide 89 text

$ git push -u origin master

Slide 90

Slide 90 text

$ git remote add origin [email protected]:example/example.git

Slide 91

Slide 91 text

pull requests

Slide 92

Slide 92 text

pull requests = awesome

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

internal use too!

Slide 98

Slide 98 text

tips & tricks

Slide 99

Slide 99 text

$ git log commit eee30254c2ba314ad7fe3bc493095af421118c27 Author: Ryan McCue Date: Fri Oct 26 00:01:26 2012 +1000 Check unknown status codes too commit 7ce9e116792697955ba32be9e18d67d37513f80b Author: Ryan McCue Date: Thu Oct 25 23:52:19 2012 +1000 Test new status headers These were previously added while in draft status, but not tested. This adds testing for those, in addition to updating the link to the new related RFC. commit 083843d9dbd4eeb0fc24fe35479d472f6bea4ff9 Merge: 3f508b0 23c2087 Author: Ryan McCue Date: Thu Oct 25 06:39:30 2012 -0700 Merge pull request #23 from rmccue/multiple Add ability to send multiple requests at once

Slide 100

Slide 100 text

$ git log --stat commit eee30254c2ba314ad7fe3bc493095af421118c27 Author: Ryan McCue Date: Fri Oct 26 00:01:26 2012 +1000 Check unknown status codes too tests/Transport/Base.php | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) commit 7ce9e116792697955ba32be9e18d67d37513f80b Author: Ryan McCue Date: Thu Oct 25 23:52:19 2012 +1000 Test new status headers These were previously added while in draft status, but not tested. This adds testing for those, in addition to updating the link to the new related RFC. library/Requests/Exception/HTTP/428.php | 4 ++-- library/Requests/Exception/HTTP/431.php | 4 ++-- library/Requests/Exception/HTTP/511.php | 4 ++-- tests/Transport/Base.php | 4 ++++ 4 files changed, 10 insertions(+), 6 deletions(-)

Slide 101

Slide 101 text

$ git pull remote: Counting objects: 677, done. remote: Compressing objects: 100% (168/168), done. Receiving objects: remote: Total 583 (delta 489), reused 505 (delta 412) Receiving objects: 100% (583/583), 125.00 KiB | 107 KiB/s, done. Resolving deltas: 100% (489/489), completed with 85 local objects. From https://github.com/WordPress/WordPress c67a081..78f0c0a master -> origin/master Updating c67a081..78f0c0a Fast-forward wp-admin/admin-ajax.php | 2 +- wp-admin/css/colors-classic.min.css | 2 +- wp-admin/css/colors-fresh.min.css | 2 +- wp-admin/css/wp-admin-rtl.css | 18 +- wp-admin/css/wp-admin-rtl.min.css | 2 +- wp-admin/css/wp-admin.css | 35 +- wp-admin/css/wp-admin.min.css | 2 +- wp-admin/custom-background.php | 21 +- wp-admin/custom-header.php | 36 +-

Slide 102

Slide 102 text

$ git pull remote: Counting objects: 677, done. remote: Compressing objects: 100% (168/168), done. Receiving objects: remote: Total 583 (delta 489), reused 505 (delta 412) Receiving objects: 100% (583/583), 125.00 KiB | 107 KiB/s, done. Resolving deltas: 100% (489/489), completed with 85 local objects. From https://github.com/WordPress/WordPress c67a081..78f0c0a master -> origin/master Updating c67a081..78f0c0a Fast-forward wp-admin/admin-ajax.php | 2 +- wp-admin/css/colors-classic.min.css | 2 +- wp-admin/css/colors-fresh.min.css | 2 +- wp-admin/css/wp-admin-rtl.css | 18 +- wp-admin/css/wp-admin-rtl.min.css | 2 +- wp-admin/css/wp-admin.css | 35 +- wp-admin/css/wp-admin.min.css | 2 +- wp-admin/custom-background.php | 21 +- wp-admin/custom-header.php | 36 +-

Slide 103

Slide 103 text

$ git log c67a081..78f0c0a commit 78f0c0a9dffb01c8d369f860f189beb9210de6b9 Author: Andrew Nacin Date: Mon Nov 12 07:47:41 2012 +0000 Revert [22421]. see #6821. see #22308. see #22419. git-svn-id: http://core.svn.wordpress.org/trunk@22549 1a063a9b-81f0-0310-95a commit 1ec12cccb9d12fdbde7c6592266fb875555c39f3 Author: Daryl Koopersmith Date: Mon Nov 12 06:02:03 2012 +0000 Media: Allow successive embed URLs. see [22547], #21390. git-svn-id: http://core.svn.wordpress.org/trunk@22548 1a063a9b-81f0-0310-95a commit 2d87f983adfc75587f544ab742619b380d9a8cdb Author: Daryl Koopersmith Date: Mon Nov 12 05:57:12 2012 +0000

Slide 104

Slide 104 text

questions?

Slide 105

Slide 105 text

1) git basics 2) efficient git 3) git + WordPress

Slide 106

Slide 106 text

Skeleton github.com/markjaquith/WordPress-Skeleton

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

submodules (like svn externals)

Slide 109

Slide 109 text

submodules ≠ awesome

Slide 110

Slide 110 text

submodules ≠ awesome try Tower?

Slide 111

Slide 111 text

keep it simple

Slide 112

Slide 112 text

site/ wp-admin/ wp-content/ wp-includes/ ...

Slide 113

Slide 113 text

$ git init Initialized empty Git repository in …/site/.git/ $ git add * $ git commit -m ‘Initial commit’ [master (root-commit) eadd213] Initial commit 2 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 .gitignore create mode 100644 .gitmodules

Slide 114

Slide 114 text

site/wp-content/plugins/bbpress/

Slide 115

Slide 115 text

$ git add wp-content/plugins/bbpress/* $ git commit -m ‘Add bbPress’ [master 26b47c0] Add bbPress 200 files changed, 62840 insertions(+), 0 deletions(-) create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-actions.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-admin.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-converter.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-forums.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-functions.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-metaboxes.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-parser.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-replies.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-settings.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-tools.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-topics.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/bbp-users.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/converters/Example.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/converters/Invision.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/converters/bbPress1.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/converters/index.php create mode 100644 wp-content/plugins/bbpress/bbp-admin/converters/phpBB.php

Slide 116

Slide 116 text

$ git remote add origin [email protected]:rmccue/test-site.git $ git push -u origin master Counting objects: 1268, done. Writing objects: 91% (1154/1268), 4.16 MiB | 13 KiB/s Compressing objects: 100% (1248/1248), done. Writing objects: 100% (1268/1268), 4.90 MiB | 15 KiB/s, done. Total 1268 (delta 128), reused 0 (delta 0) To [email protected]:rmccue/test-site.git * [new branch] master -> master Branch master set up to track remote branch master from origin.

Slide 117

Slide 117 text

WP Australia github.com/BronsonQuick/wpaustralia

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

Wrong

Slide 120

Slide 120 text

Wrong (sorry Bronson)

Slide 121

Slide 121 text

try it anyway!

Slide 122

Slide 122 text

I am going to lie to you Warning:

Slide 123

Slide 123 text

one last thing

Slide 124

Slide 124 text

No content

Slide 125

Slide 125 text

that’s it

Slide 126

Slide 126 text

questions? http://journal.ryanmccue.info/185 http://windows.github.com/ http://mac.github.com/ http://www.git-tower.com/ http://try.github.com/ http://github.com/markjaquith/WordPress-Skeleton http://github.com/BronsonQuick/wpaustralia Ryan McCue http://ryanmccue.info/ @rmccue