Git & GitHub & Open Source (Clermont'ech Workshop Git)

Git & GitHub & Open Source (Clermont'ech Workshop Git)

In this talk, you will learn how to use Git and GitHub in an efficient manner, but also how to manage Open Source projects, and what it actually means.

Online slides: http://slides.williamdurand.fr/git-and-github-and-open-source/
Sources: https://github.com/willdurand-slides/git-and-github-and-open-source

F59d2f1ed66b8d9c6ceebea5a748494b?s=128

William Durand

November 15, 2014
Tweet

Transcript

  1. Git & GitHub & Open Source William Durand ‑ November

    15th, 2014
  2. Open Source

  3. In production and development, Open Source as a development model

    promotes a universal access via a free license to a product's design or blueprint [...]. http://en.wikipedia.org/wiki/Open_source
  4. Open‑source software is very often developed in a public, collaborative

    manner.
  5. ® GitHub

  6. None
  7. GitHub is the largest code host on the planet with

    over 17.1 million repositories.
  8. Integrated Issue Tracking

  9. Integrated Issue Tracking

  10. Syntax Highlighting

  11. Collaborative Code Review

  12. Collaborative Code Review

  13. Pull Request = Code + Issue + Code Comments

  14. GitHub Pages

  15. Release Management

  16. Compare View

  17. GitHub Tip #1

  18. t File Finder

  19. How To Contribute?

  20. Everyone can contribute.

  21. Fork The Repository

  22. Create A Branch git checkout -b feature-branch

  23. Eat, Sleep, Code, Repeat.

  24. Submit A Pull Request But, how?

  25. Look At The CONTRIBUTING File (If it does not exist,

    contribute by adding it!)
  26. Write Good Commit Messages Capitalized, short (50 chars or less)

    summary More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. In some contexts, the first line is treated as the subject of an email and the rest of the text as the body. The blank line separating the summary from the body is critical (unless you omit the body entirely); tools like rebase can get confused if you run the two together. Write your commit message in the imperative: "Fix bug" and not "Fixed bug" or "Fixes bug." This convention matches up with commit messages generated by commands like git merge and git revert. Further paragraphs come after blank lines. Å A Note About Git Commit Messages
  27. Rebase Your Branch

  28. Squash Your Commits git rebase -i HEAD~2 pick 5335450 add

    test pick 4c20f8d Fix undefined variable # Rebase 35124cb..4c20f8d onto 35124cb # # Commands: # p, pick = use commit # r, reword = use commit, but edit the commit message # e, edit = use commit, but stop for amending # s, squash = use commit, but meld into previous commit # f, fixup = like "squash", but discard this commit's log message # x, exec = run command (the rest of the line) using shell # # These lines can be re-ordered; they are executed from top to bottom. # # If you remove a line here THAT COMMIT WILL BE LOST. # # However, if you remove everything, the rebase will be aborted. # # Note that empty commits are commented out Å Squashing commits with rebase
  29. Push & Create

  30. Profit!

  31. What Happens Then?

  32. An Open Source maintainer will look at your work.

  33. Pull Request Review Understand the goal of the PR Try

    to reproduce the issue Try the fix Test the new feature Think about edge cases Write documentation if not provided
  34. Dealing With Releases

  35. Semantic Versioning MAJOR.MINOR.PATCH Å semver.org

  36. Changelog A change log is a file which contains a

    curated, ordered list of notable changes for each version of a project. Å keepachangelog.com
  37. Release Process 1. Run test suite(s) 2. Update documentation, changelog,

    version 3. git commit -m "Prepare X.Y.Z release" 4. git tag vX.Y.Z 5. Build artifact (gem build, etc.) 6. Update version number (Z++) 7. git commit -m "Bump version to X.Y.Z+1-dev" 8. git push origin master --tags 9. Publish artifact (gem push, etc.) 10. Publish a GitHub release
  38. hub git + hub = github alias git=hub

  39. Clone git clone random/repo # git clone git://github.com/random/repo.git git clone

    repo # git clone git://github.com/YOUR/repo.git
  40. Browse git browse # open https://github.com/random/repo git browse -- issues

    # open https://github.com/random/repo/issues
  41. Easy Fetch git fetch ubermuda # git remote add ubermuda

    git://github.com/ubermuda/repo.git # git fetch ubermuda
  42. Checkout git checkout https://github.com/your/repo/pull/123 # git remote add contributor git://github.com/contributor/repo.git

    # git fetch contributor # git checkout -b contributor-branch contributor/branch Best way to [work on|review|test] a Pull Request so far!
  43. Apply Commits git am -3 https://github.com/your/repo/pull/123

  44. Cherry‑Pick git cherry-pick https://github.com/random/repo/commit/SHA # git remote random git://github.com/random/repo.git #

    git fetch random # git cherry-pick SHA
  45. More! git fork, git pull-request, merge, ci-status, etc. Å hub.github.com

  46. Dealing With PATCH & DIFF

  47. Creating A Patch git format-patch master --stdout > fix-undefined-variable.patch From:

    William Durand <william.durand1@gmail.com> Date: Thu, 13 Nov 2014 10:22:17 +0100 Subject: [PATCH] Fix undefined variable --- test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.js b/test.js index 760e4eb..60ac996 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ (function () { - var i; + var i, j; i = 0; j = i; -- 2.1.2
  48. Changes Overview git apply --stat fix-undefined-variable.patch test.js | 2 +-

    1 file changed, 1 insertion(+), 1 deletion(-)
  49. Test The Patch git apply --check fix-undefined-variable.patch No output ==

    ›
  50. Then, Apply git am --signoff < fix-undefined-variable.patch Applying: Fix undefined

    variable commit 4c20f8d517b99638f5379f3f0894ad076d2b6a5b Author: William Durand <william.durand1@gmail.com> Date: Thu Nov 13 10:22:17 2014 +0100 Fix undefined variable Signed-off-by: William Durand <william.durand1@gmail.com> BTW, patch -p1 works too!
  51. GitHub Tip #2

  52. .patch https://github.com/your/repo/commit/e0af340837978f80d8cd144a4475.patch

  53. Applying A Commit As A Patch curl https://github.com/your/repo/commit/<SHA>.patch |git am

    Applying: Fix undefined variable
  54. .diff https://github.com/your/repo/commit/e0af340837978f80d8cd144a4475.diff

  55. Dealing With Everything Else

  56. Fixing The Code Is Not Enough

  57. Full‑Time Hobby

  58. Just do it.

  59. Provide Support

  60. ... Everywhere

  61. Create Things That People Actually Use (& Like)

  62. Inspire Others

  63. Makes People Feel Good

  64. Receive Overwhelming Feedback

  65. ... & Gifts

  66. Thank You. Questions? ¾ ® ¬ williamdurand.fr github.com/willdurand twitter.com/couac

  67. Bonus: (My) Useful Git Commands

  68. Atomic Commits git add -p diff --git a/test.js b/test.js index

    60ac996..2a57310 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,5 @@ (function () { - var i, j; + var i = 0, j; - i = 0; - j = i; + j = 1; })(); Stage this hunk [y,n,q,a,d,/,s,e,?]? s Split into 2 hunks. @@ -1,3 +1,3 @@ (function () { - var i, j; + var i = 0, j; Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]?
  69. Amending A Commit git commit --amend -m 'Fix undefined variable

    j Fix #123'
  70. Fast Pull & Rebase git pull --rebase origin master

  71. Go Back git checkout - Switched to branch 'master' git

    checkout - Switched to branch 'feat-undefined-variable'
  72. (Un)Merged Branch git branch --no-merged develop feat-another-feature feat-my-feature fix-undefined-variable git

    branch --merged * master
  73. Links http://williamdurand.fr/2013/11/20/on‑creating‑pull‑requests/ http://gitready.com/advanced/2009/02/10/squashing‑commits‑with‑rebase.html http://git‑scm.com/book/en/v2/Git‑Branching‑Rebasing http://tbaggery.com/2008/04/19/a‑note‑about‑git‑commit‑messages.html