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. 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
  2. 6.
  3. 7.

    GitHub is the largest code host on the planet with

    over 17.1 million repositories.
  4. 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
  5. 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
  6. 30.
  7. 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
  8. 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
  9. 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
  10. 40.
  11. 41.

    Easy Fetch git fetch ubermuda # git remote add ubermuda

    git://github.com/ubermuda/repo.git # git fetch ubermuda
  12. 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!
  13. 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
  14. 48.
  15. 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!
  16. 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,?]?
  17. 71.

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

    checkout - Switched to branch 'feat-undefined-variable'