Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Git + Using Git with WordPress

Ryan McCue
November 13, 2012

Introduction to Git + Using Git with WordPress

An introduction to Git basics, building up to more advanced topics. Also includes information on using Git to develop WordPress slides.

Ryan McCue

November 13, 2012
Tweet

More Decks by Ryan McCue

Other Decks in Programming

Transcript

  1. 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
  2. $ 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
  3. $ 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(-)
  4. $ 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,?]?
  5. 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
  6. $ 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.
  7. $ git log commit eee30254c2ba314ad7fe3bc493095af421118c27 Author: Ryan McCue <[email protected]> Date:

    Fri Oct 26 00:01:26 2012 +1000 Check unknown status codes too commit 7ce9e116792697955ba32be9e18d67d37513f80b Author: Ryan McCue <[email protected]> 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 <[email protected]> Date: Thu Oct 25 06:39:30 2012 -0700 Merge pull request #23 from rmccue/multiple Add ability to send multiple requests at once
  8. $ git log --stat commit eee30254c2ba314ad7fe3bc493095af421118c27 Author: Ryan McCue <[email protected]>

    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 <[email protected]> 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(-)
  9. $ 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 +-
  10. $ 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 +-
  11. $ git log c67a081..78f0c0a commit 78f0c0a9dffb01c8d369f860f189beb9210de6b9 Author: Andrew Nacin <[email protected]>

    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 <[email protected]> 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 <[email protected]> Date: Mon Nov 12 05:57:12 2012 +0000
  12. $ 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
  13. $ 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
  14. $ 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.