Pro Yearly is on sale from $80 to $50! »

Develop Very Mild Super Powers with Git

Develop Very Mild Super Powers with Git

WordCamp Chicago 2014 presentation introducing Git and the mild superpowers it endows.

5ecaa75cfaa9f359c001705a999e8e99?s=128

Brent Shepherd

June 14, 2014
Tweet

Transcript

  1. None
  2. http://brent.io @thenbrent

  3. Who is using version control? Who is using git? Slides:

    http://goo.gl/fxDP0W
  4. getting started with git Git superpowers Slides: http://goo.gl/fxDP0W

  5. /wp-content/plugins/myplugin/myplugin.php Version waaaaat Slides: http://goo.gl/fxDP0W

  6. /wp-content/plugins/myplugin/myplugin.php myplugin.php.old Version waaaaat Slides: http://goo.gl/fxDP0W

  7. /wp-content/plugins/myplugin/myplugin.php myplugin.php.old myplugin.php.old.2 myplugin.php.old.3 myplugin.php.old.4 myplugin.php.alt Version waaaaat Slides: http://goo.gl/fxDP0W

  8. WP-API W ordPress/book and more Slides: http://goo.gl/fxDP0W

  9. ! working tree ! not wow so bisect merge conflict

    ! DETACHED HEAD ! much commands merge-octopus ! confuse
  10. terminal vs. gui Marvel Character Trademarks & Copyright © 1941-2014

    Marvel Characters, Inc. ALL RIGHTS RESERVED. Source: http://marvel.wikia.com/File:Kavita_Rao_(Earth-616)_reveals_the_Hope_Serum_(The_Cure).jpg
  11. git basics

  12. git basics I <3 @rmccue

  13. $cd /plugins/my-plugin/ $git init

  14. $cd /plugins/my-plugin/ $git init Initialized empty Git repository in /

    plugins/my-plugin
  15. W orking T ree ! /my-theme/ index.php style.css git repository

    !
  16. W orking T ree ! /my-theme/ index.php style.css git repository

    ! Committed
  17. W orking T ree ! /my-theme/ index.php style.css git repository

    ! /my-theme/ index.php style.css $ git commit -a
  18. What if I only want to COMMIT SOME of my

    changes?
  19. W orking T ree ! /my-theme/ index.php style.css repository !

    /my-theme/ index.php style.css index ! /my-theme/ index.php style.css multidimensional
  20. W orking T ree ! /my-theme/ index.php style.css repository !

    /my-theme/ index.php style.css index ! /my-theme/ index.php style.css multidimensional Staging Area
  21. W orking T ree ! /my-theme/ index.php style.css repository !

    /my-theme/ index.php style.css index ! /my-theme/ index.php style.css
  22. W orking T ree ! /my-theme/ index.php style.css repository !

    /my-theme/ index.php style.css index ! /my-theme/ index.php style.css $ git commit $ git add
  23. W orking T ree ! /my-theme/ index.php style.css repository !

    /my-theme/ index.php style.css index ! /my-theme/ index.php style.css $ git commit $ git add
  24. W orking T ree ! /my-theme/ index.php style.css repository !

    /my-theme/ index.php style.css index ! /my-theme/ index.php style.css $ git commit $ git add $ git reset $ git checkout
  25. multimultidimensional Local Repository ! /my-theme/ index.php style.css Remote repository(s) !

    /my-theme/ index.php style.css
  26. Local Repository ! /my-theme/ index.php style.css Remote repository(s) ! /my-theme/

    index.php style.css e.g. on GitHub multimultidimensional
  27. Local ! /my-theme/ index.php style.css Remote

  28. Local ! /my-theme/ index.php style.css Remote ! /my-theme/ index.php style.css

    $ git push origin master
  29. Local ! /my-theme/ index.php style.css Remote ! /my-theme/ index.php style.css

    $ git push origin master
  30. Local ! /my-theme/ index.php style.css Remote ! /my-theme/ index.php style.css

    $ git push origin master $ git pull origin master
  31. https://try .github.io

  32. Mild superpowers

  33. Everything I just showed you is wrong. wrong. wrong.

  34. -p

  35. git add -p

  36. git commit -p

  37. git checkout -p

  38. None
  39. $git status On branch master ! Changes not staged for

    commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) ! modified: changelog.txt modified: classes/class-wc-subscriptions-cart.php modified: languages/woocommerce-subscriptions.pot modified: woocommerce-subscriptions.php ! no changes added to commit (use "git add" and/or "git commit - a")
  40. $git add -p changelog.txt diff --git a/changelog.txt b/changelog.txt index 274d1ae..5624ae9

    100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,6 @@ *** WooCommerce Subscriptions Changelog *** -2014.06.nn - version 1.5.4 +2014.06.12 - version 1.5.4 + * New: 'processed_subscription_renewal_payment' hook + * Tweak: allow admin to limit subscription by status * Tweak: improve shipping price displayed in the order totals table after checkout and via the My Account page when the order includes recurring shipping Stage this hunk [y,n,q,a,d,/,e,?]?
  41. 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 or any of the remaining ones a - stage this hunk and all later hunks in the file d - do not stage this hunk or 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 @@ -1,6 +1,6 @@ *** WooCommerce Subscriptions Changelog *** Atomic Commits FTW
  42. Eidetic Memory Character Trademarks & Copyright © 1941-2014 Marvel Characters,

    Inc. ALL RIGHTS RESERVED. Source: http://x-men.wikia.com/wiki/Sage
  43. $git log

  44. $git log commit 45e9b78e34fc58854d818ef69f16127c5c5db7fa Author: thenbrent <thenbrent@gmail.com> Date: Wed Jun

    11 23:53:35 2014 -0700 ! Handle 'on-hold' subscriptions with limited subs For subscriptions limited to 'active' ! commit ed0063a184cbe2885dd08d28d82be55dfc0b3bab Author: thenbrent <thenbrent@gmail.com> Date: Wed Jun 11 23:50:16 2014 -0700 ! Squashed 'lib/action-scheduler/' changes from f2dfcb8..082b09a 082b09a Merge branch 'bleeding_branch' of github.com:thenbrent/action- scheduler into bleeding_bran 7212468 Consolidate confusing 'Run'/'Process' action links 9ab29bd Fix logic for showing AS admin screen git-subtree-dir: lib/action-scheduler git-subtree-split: 082b09a17833be5861f0295088ef19e11b47a815
  45. $git log --stat -1

  46. $git log --stat -1 commit 45e9b78e34fc58854d818ef69f16127c5c5db7fa Author: thenbrent <thenbrent@gmail.com> Date:

    Wed Jun 11 23:53:35 2014 -0700 ! Handle 'on-hold' subscriptions with limited subs For subscriptions limited to 'active' ! classes/class-wc-product-subscription.php | 2 +- classes/class-wc-product-variable-subscription.php | 2 +- templates/single-product/add-to-cart/subscription.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-)
  47. $git log v2.1.8...v2.1.9 --oneline

  48. $git log v2.1.8...v2.1.9 --oneline de27bb7 TX update 4e2c6c8 readme f8be405

    Update class-wc-validation.php 2b8b483 Grunt/pot/tx 4eda361 Readme a1c0b77 normalized the woocommerce_email_attachments filter return type 0e102a0 fixed some coding standards in includes/class-wc-ajax.php 19625d1 Fix notice when not scanning any files Closes #5465 c5c81c0 Check if term is returned before getting its name a059290 Update class-wc-meta-box-coupon-data.php 10c1a18 Uttaranchal (UT) renamed to Uttarakhand (UK) c945e5a Conflict 4a63bb1 Brackets f68f278 Brahmanbaria & Habiganj missing from the list 484b492 Cleaned up logic in email_instructions functions for @splashingpixels 025f06a Use WP SEO class method rather than deprecated fn 1f12370 defined a min value to cart quantity input fcfaff1 hide number input buttons in firefox 29 and later d8ac99d COD: check if cart is available before checking if it needs shipping ad5e6a4 param comment Fixes #5408 b6c4d9a Trim commas and empty lines off address formats Fixes #5411 616542b Revise how variation attributes are deleted/updated 121022a Add $package to is_available shipping method hooks debe308 Closes #5424 15b10ca Update abstract-wc-shipping-method.php a2759cb COD: no need to hide in admin 27b302b Fix fee/coupon lines typo in REST API order response 97e0449 Stop sending line items to Mijireh Fixes #5365
  49. $git diff v2.1.8...v2.1.9

  50. $git diff v2.1.8...v2.1.9 diff --git a/assets/css/woocommerce.css b/assets/css/woocommerce.css index 95531a0..e5d48a1 100644

    --- a/assets/css/woocommerce.css +++ b/assets/css/woocommerce.css @@ -1 +1 @@ -.clear{clear:both}.nobr{white-space:nowrap}@font-face{font-family:star;src:url(../fonts/star.eot);src:url( \ No newline at end of file +.clear{clear:both}.nobr{white-space:nowrap}@font-face{font-family:star;src:url(../fonts/star.eot);src:url( \ No newline at end of file diff --git a/assets/css/woocommerce.less b/assets/css/woocommerce.less index ee357de..0d23cce 100644 --- a/assets/css/woocommerce.less +++ b/assets/css/woocommerce.less @@ -683,6 +683,7 @@ p.demo_store { .inset_box_shadow( 0, 0, 2px, 0, @secondary ); font-weight:bold; .border_radius_left(2px); + -moz-appearance: textfield; /* Hide buttons for Firefox 29 and later */ } /* Hide buttons for opera */ @@ -1849,4 +1850,4 @@ p.demo_store { } } } -} \ No newline at end of file +} diff --git a/i18n/languages/woocommerce-admin-bg_BG.mo b/i18n/languages/woocommerce-admin-bg_BG.mo index 6c976c2..025c10f 100644 Binary files a/i18n/languages/woocommerce-admin-bg_BG.mo and b/i18n/languages/woocommerce-admin-bg_BG.mo differ diff --git a/i18n/languages/woocommerce-admin-bg_BG.po b/i18n/languages/woocommerce-admin-bg_BG.po index b09a278..0eaf03d 100644 --- a/i18n/languages/woocommerce-admin-bg_BG.po +++ b/i18n/languages/woocommerce-admin-bg_BG.po
  51. Replication Character Trademarks & Copyright © 1941-2014 Marvel Characters, Inc.

    ALL RIGHTS RESERVED. Source: http://marvel.wikia.com/James_Madrox_(Earth-616)
  52. $git clone git@github.com:woothemes/woocommerce.git copy remote repo

  53. $git clone git@github.com:woothemes/woocommerce.git Cloning into 'woocommerce'... remote: Reusing existing pack:

    53925, done. remote: Counting objects: 52, done. remote: Compressing objects: 100% (52/52), done. remote: Total 53977 (delta 25), reused 0 (delta 0) Receiving objects: 100% (53977/53977), 81.17 MiB | 1.85 MiB/s, done. Resolving deltas: 100% (39662/39662), done. Checking connectivity... done. copy remote repo
  54. $git branch * master $ intra-repository replication

  55. $git branch * master $git branch issue/12358 $ intra-repository replication

  56. $git branch * master $git branch issue/12358 $git branch issue/12358

    * master intra-repository replication
  57. $git branch * master $git branch issue/12358 $git branch issue/12358

    * master $git checkout issue/12358 $git branch issue/12358 * master intra-repository replication
  58. $git branch * master $git checkout -b issue/12358 $git branch

    * issue/12358 master intra-repository replication
  59. $git branch * master $git checkout -b issue/12358 $git branch

    feature/order_factory feature/create_order_function issue/132135 issue/12358 master version/2.1.1 version/2.1.2 version/2.1.2 intra-repository replication
  60. Character Trademarks & Copyright © 1941-2014 Marvel Characters, Inc. ALL

    RIGHTS RESERVED. Source: http://powerlisting.wikia.com/wiki/File:MultipleMan.jpg Which Branch am I ?!
  61. Git Aware Prompt FTW https://github.com/jimeh/git-aware-prompt http://www .bramschoenmakers.nl/en/node/624 And Many More…

  62. (master)$git branch * master (master)$git branch issue/358 (master)$git checkout issue/358

    (issue/358)$git checkout master (master)$git checkout -b feature/orderfactory (feature/orderfactory)$ Git Aware Prompt
  63. Unification Character Trademarks & Copyright © 1941-2014 Marvel Characters, Inc.

    ALL RIGHTS RESERVED. Source: http://marvel.wikia.com/James_Madrox_(Earth-616)
  64. (issue/358)$git log --oneline c7410a1 send proper status codes on die

    4812248 Sends proper HTTP Status Codes on die (issue/358)$git checkout master (master)$git merge issue/358 Updating 1274ac3.. 4812248 Fast-forward includes/admin/class-wc-admin-notices.php | 4 +- includes/admin/class-wc-admin-settings.php | 6 +- includes/admin/class-wc-admin-taxonomies.php | 4 +- 3 files changed, 14 insertions(+), 14 deletions(-) (master)$ Merging Replicas
  65. (issue/358)$git log --oneline c7410a1 send proper status codes on die

    4812248 Sends proper HTTP Status Codes on die (issue/358)$git checkout master (master)$git cherry-pick 4812248 [master bfad908] Sends proper HTTP Status Codes on die (master)$ Cherry Picking
  66. Interdimensional Eidetic Memory Character Trademarks & Copyright © 1941-2014 Marvel

    Characters, Inc. ALL RIGHTS RESERVED. Source: http://en.wikipedia.org/wiki/File:Xav-lopr.png
  67. $git reflog

  68. $git reflog 61a946c HEAD@{0}: checkout: moving from 1557151babc01af7954c to 2.1.11

    61a946c HEAD@{1}: checkout: moving from master to v2.1.11 92e98be HEAD@{2}: checkout: moving from 2.1.11 to master 61a946c HEAD@{3}: checkout: moving from 2.1.9 to 2.1.11 de27bb7 HEAD@{4}: checkout: moving from 2.1.7 to 2.1.9 da07586 HEAD@{5}: checkout: moving from master to 2.1.7 92e98be HEAD@{6}: checkout: moving from dd0b50c2647b8f7c94a to master dd0b50c HEAD@{7}: checkout: moving from 2.1.7 to v2.0.20 da07586 HEAD@{8}: checkout: moving from master to 2.1.7 92e98be HEAD@{9}: pull woothemes master: Fast-forward ebb6af9 HEAD@{10}: checkout: moving from 2.1.6 to master 95065b6 HEAD@{11}: checkout: moving from master to 2.1.6 ebb6af9 HEAD@{12}: pull: Fast-forward c7e6a77 HEAD@{13}: checkout: moving from 2.1.5 to master f38119b HEAD@{14}: checkout: moving from master to 2.1.5 c7e6a77 HEAD@{15}: commit: Add wc_cart_totals_taxes_total_html() 49be799 HEAD@{16}: commit: Add 'woocommerce_cart_taxes_total' filter 0dcfb79 HEAD@{17}: checkout: moving from 2.1.5 to master f38119b HEAD@{18}: checkout: moving from master to 2.1.5 0dcfb79 HEAD@{19}: pull: Fast-forward !
  69. $git reflog 61a946c HEAD@{0}: checkout: moving from 1557151babc01af7954c to 2.1.11

    61a946c HEAD@{1}: checkout: moving from master to v2.1.11 92e98be HEAD@{2}: checkout: moving from 2.1.11 to master 61a946c HEAD@{3}: checkout: moving from 2.1.9 to 2.1.11 de27bb7 HEAD@{4}: checkout: moving from 2.1.7 to 2.1.9 da07586 HEAD@{5}: checkout: moving from master to 2.1.7 92e98be HEAD@{6}: checkout: moving from dd0b50c2647b8f7c94a to master dd0b50c HEAD@{7}: checkout: moving from 2.1.7 to v2.0.20 da07586 HEAD@{8}: checkout: moving from master to 2.1.7 92e98be HEAD@{9}: pull woothemes master: Fast-forward ebb6af9 HEAD@{10}: checkout: moving from 2.1.6 to master 95065b6 HEAD@{11}: checkout: moving from master to 2.1.6 ebb6af9 HEAD@{12}: pull: Fast-forward c7e6a77 HEAD@{13}: checkout: moving from 2.1.5 to master f38119b HEAD@{14}: checkout: moving from master to 2.1.5 c7e6a77 HEAD@{15}: commit: Add wc_cart_totals_taxes_total_html() 49be799 HEAD@{16}: commit: Add 'woocommerce_cart_taxes_total' filter 0dcfb79 HEAD@{17}: checkout: moving from 2.1.5 to master f38119b HEAD@{18}: checkout: moving from master to 2.1.5 0dcfb79 HEAD@{19}: pull: Fast-forward ! Y our Undo Button For Git
  70. absorb powers of others Trademarks & Copyright © NBCUniversal, Inc.

    ALL RIGHTS RESERVED. Source: http://heroeswiki.com/File:The_Man_with_the_Golden_Gun.jpg
  71. $git subtree add --prefix lib/action- scheduler git@github.com:flightless/ action-scheduler.git master --squash

    $
  72. $git subtree pull --prefix lib/action- scheduler git@github.com:flightless/ action-scheduler.git master --squash

    $
  73. absorb the powers and psyche of others Character Trademarks &

    Copyright © 1941-2014 Marvel Characters, Inc. ALL RIGHTS RESERVED. Source: http://en.wikipedia.org/wiki/Rogue_(comics)#mediaviewer/File:Rogue2CoverByMikeWieringo.jpg.gif
  74. $git subtree add --prefix lib/action- scheduler git@github.com:flightless/ action-scheduler.git master --squash

    $
  75. Rewrite History Trademarks & Copyright © NBCUniversal, Inc. ALL RIGHTS

    RESERVED. Source: http://yattaaaaa.com/
  76. $git log --pretty=oneline -1 ebd01ab1e7ee796b2cdfe164 Update pto file

  77. $git log --pretty=oneline -1 ebd01ab1e7ee796b2cdfe164 Update pto file $git commit

    --amend
  78. $git log --pretty=oneline -1 ebd01ab1e7ee796b2cdfe164 Update pto file $git commit

    --amend [master 4f0ae43] Update pot file 1 file changed, 434 insertions(+), 421 deletions(-)
  79. Rewind Time Character Copyright © 2014 Channel Four Television Corporation

    Source: http://lyra-journal.blog.cz/1301/misfits-1-serie-2009
  80. $git rebase -i HEAD~5

  81. 1 pick 03bb047 Semantics 2 pick 45e9b78 Handle 'on-hold' subscriptions

    with limited subs 3 pick 0f58231 Remove "Renewal of ..." on cart renewals 4 pick a0a17b6 Set v1.5.4 ready for release 5 pick ebd01ab Update pot file 6 7 # Rebase ca570b9..ebd01ab onto ca570b9 8 # 9 # Commands: 10 # p, pick = use commit 11 # r, reword = use commit, but edit the commit message 12 # e, edit = use commit, but stop for amending 13 # s, squash = use commit, but meld into previous commit 14 # f, fixup = like "squash", but discard this commit's log message 15 # x, exec = run command (the rest of the line) using shell 16 #
  82. 1 reword 03bb047 Semantics 2 pick 45e9b78 Handle 'on-hold' subscriptions

    with limited subs 3 edit 0f58231 Remove "Renewal of ..." on cart renewals 4 pick a0a17b6 Set v1.5.4 ready for release 5 pick ebd01ab Update pot file 6 7 # Rebase ca570b9..ebd01ab onto ca570b9 8 # 9 # Commands: 10 # p, pick = use commit 11 # r, reword = use commit, but edit the commit message 12 # e, edit = use commit, but stop for amending 13 # s, squash = use commit, but meld into previous commit 14 # f, fixup = like "squash", but discard this commit's log message 15 # x, exec = run command (the rest of the line) using shell 16 #
  83. cerebro for your code’s History Character Trademarks & Copyright ©

    1941-2014 Marvel Characters, Inc. ALL RIGHTS RESERVED. Source: http://next2012.webs.com/apps/photos/photo?photoID=169859383
  84. $git bisect start $git bisect bad $git bisect good v2.0.20

    Bisecting: a merge base must be tested [8ec3ee7a855841582068226d46802f84b9b6328c] 2.0.12 version bump
  85. $git bisect start $git bisect bad $git bisect good v2.0.20

    Bisecting: a merge base must be tested [8ec3ee7a855841582068226d46802f84b9b6328c] 2.0.12 version bump $git bisect good Bisecting: 1751 revisions left to test after this (roughly 11 steps) [70a5004ff90b7470d5f498e8780bfc28656c054e] Merge pull request #4512 from claudiosmweb/fix_4509 $
  86. $git blame -w includes/wc-notice-functions.php

  87. $git blame -w includes/wc-notice-functions.php 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42

    +0100 1) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 2) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 3) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 4) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 5) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 6) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 7) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 8) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 9) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 10) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 11) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 12) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 13) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 14) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 15) 376c2f26 includes/wc-notice-functions.php (thenbrent 2013-11-13 15:56:01 -0800 16) 376c2f26 includes/wc-notice-functions.php (thenbrent 2013-11-13 15:56:01 -0800 17) b3aad6f6 includes/wc-notice-functions.php (thenbrent 2013-11-12 16:16:27 -0800 18) 376c2f26 includes/wc-notice-functions.php (thenbrent 2013-11-13 15:56:01 -0800 19) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 20) 17167288 includes/wc-message-functions.php (Mike Jolley 2013-06-11 15:59:42 +0100 21) b3aad6f6 includes/wc-notice-functions.php (thenbrent 2013-11-12 16:16:27 -0800 22) b3aad6f6 includes/wc-notice-functions.php (thenbrent 2013-11-12 16:16:27 -0800 23)
  88. When in need of solace, git frost http://www .mynameismichelle.com/product/git-frost-poetry-poster/

  89. http://journal.ryanmccue.info/185/intro-to-git/ ! http://www-cs-students.stanford.edu/~blynn/gitmagic/ ! https://github.com/markjaquith/WordPress-Skeleton ! Google is your friend.

    Continue your T raining
  90. Thank Y ou

  91. W ant to try multiplayer Git?

  92. All Marvel characters and the distinctive likeness(es) thereof are Trademarks

    & Copyright © 2005 Marvel Characters, Inc. ALL RIGHTS RESERVED.