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

Git & GitHub & Open Source (Clermont'ech Worksh...

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

William Durand

November 15, 2014
Tweet

More Decks by William Durand

Other Decks in Technology

Transcript

  1. 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. GitHub is the largest code host on the planet with

    over 17.1 million repositories.
  3. 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
  4. 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
  5. 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
  6. Changelog A change log is a file which contains a

    curated, ordered list of notable changes for each version of a project. Å keepachangelog.com
  7. 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
  8. Easy Fetch git fetch ubermuda # git remote add ubermuda

    git://github.com/ubermuda/repo.git # git fetch ubermuda
  9. 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!
  10. Creating A Patch git format-patch master --stdout > fix-undefined-variable.patch From:

    William Durand <[email protected]> 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
  11. Then, Apply git am --signoff < fix-undefined-variable.patch Applying: Fix undefined

    variable commit 4c20f8d517b99638f5379f3f0894ad076d2b6a5b Author: William Durand <[email protected]> Date: Thu Nov 13 10:22:17 2014 +0100 Fix undefined variable Signed-off-by: William Durand <[email protected]> BTW, patch -p1 works too!
  12. 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,?]?
  13. Go Back git checkout - Switched to branch 'master' git

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