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

Git & Open Source & Collaboration

Git & Open Source & Collaboration

Talk on Git, Open Source, and collaborative patterns (a.k.a. workflows). This is a short-version of my "Git & GitHub & Open Source" talk I gave at LavaJUG: https://speakerdeck.com/willdurand/2015.

William Durand

January 28, 2016
Tweet

More Decks by William Durand

Other Decks in Programming

Transcript

  1. GIT & OPEN SOURCE
    & COLLABORATION
    William Durand - January 28th, 2016 @ Michelin

    View Slide

  2. DISCLAIMER: I am not working at GitHub.

    View Slide

  3. "MACRO" AGENDA
    1. Git
    2. Git(Hub|Lab)
    3. Workflows
    4. Open Source

    View Slide

  4. dž

    View Slide

  5. Git is a widely used version control system for software
    development. It is a distributed revision control system.
    Å https://en.wikipedia.org/wiki/Git_(software)

    View Slide

  6. Credit: https://aht.github.io/whatisgit/

    View Slide

  7. GIT FOR NEWCOMERS
    Å try.github.io

    View Slide

  8. ® GITHUB

    View Slide

  9. View Slide

  10. GitHub is the largest code host on the planet
    with over
    29.5 million
    repositories.

    View Slide

  11. SOCIAL CODING

    View Slide

  12. INTEGRATED ISSUE TRACKING

    View Slide

  13. INTEGRATED ISSUE TRACKING

    View Slide

  14. SYNTAX HIGHLIGHTING

    View Slide

  15. COLLABORATIVE CODE REVIEW

    View Slide

  16. COLLABORATIVE CODE REVIEW

    View Slide

  17. PULL REQUEST (PR)
    Pull Request = Code + Issue + Code Comments

    View Slide

  18. COMPARE VIEW

    View Slide

  19. RELEASE MANAGEMENT

    View Slide

  20. TEAM MANAGEMENT

    View Slide

  21. OUTSIDE COLLABORATORS

    View Slide

  22. PER PROJECT COLLABORATORS

    View Slide

  23. PROTECTED BRANCHES

    View Slide

  24. DEPLOYMENT MANAGEMENT

    View Slide

  25. HUB
    git + hub = github \o/
    Å hub.github.com

    View Slide

  26. GITLAB
    (quickly)

    View Slide

  27. View Slide

  28. GitLab is an
    Open Source
    (MIT licensed) web-based Git
    repository manager with wiki and issue tracking features.

    View Slide

  29. GitLab started a side project in 2011.
    In 2015, more than 800 (worldwide) contributors, 10+
    employees, and 1.5M raised in seed funding in July.

    View Slide

  30. GETTING STARTED
    On your
    In your company
    gitlab.com
    git.framasoft.org
    Raspberry Pi
    Pro-tip:
    Merge Request ≈ Pull Request

    View Slide

  31. WORKFLOWS
    a.k.a. collaboration patterns

    View Slide

  32. CENTRALIZED
    Shared repository (subversion-style)

    View Slide

  33. RELEASE (OR INTEGRATION) MANAGER
    Blessed repository + a release manager

    View Slide

  34. DICTATOR AND LIEUTENANTS
    Blessed repository + trusted lieutenants and a dictator

    View Slide

  35. GIT FLOW
    " "
    A successful Git branching model
    Well... Maybe not. See
    instead.
    this simple
    git branching model

    View Slide

  36. GITHUB FLOW
    Å
    Understanding the GitHub Flow

    View Slide

  37. GITLAB FLOW
    Å GitLab Flow

    View Slide

  38. POUCE DRIVEN DEVELOPMENT
    › + › = Good to merge/ship

    View Slide

  39. OPEN SOURCE

    View Slide

  40. 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

    View Slide

  41. Open-source software is very often developed
    in a
    public
    ,
    collaborative
    manner.

    View Slide

  42. HOW TO CONTRIBUTE?

    View Slide

  43. Everyone can contribute.

    View Slide

  44. FORK THE REPOSITORY

    View Slide

  45. CREATE A BRANCH
    git checkout -b feature-branch

    View Slide

  46. EAT, SLEEP, CODE, REPEAT.

    View Slide

  47. SUBMIT A PULL REQUEST
    But, how?

    View Slide

  48. LOOK AT THE CONTRIBUTING FILE
    (If it does not exist, contribute by adding it!)

    View Slide

  49. 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

    View Slide

  50. FIRST LINE ≤ 50 CHARS, PRESENT IMPERATIVE
    "Subject of an email"
    Emojis all the things! (like )
    Atom

    View Slide

  51. (Blank line before details)
    DETAILS LINES ≤ 72 CHARS: EXPLAIN WHAT YOU DID
    "Body of an email"
    (GFM):
    G
    itHub
    F
    lavored
    M
    arkdown
    Italics, bold
    URL autolinking
    Syntax highlighting
    Auto-close issues
    : Fix #123
    and more!

    View Slide

  52. REBASE YOUR BRANCH

    View Slide

  53. 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

    View Slide

  54. PUSH & CREATE

    View Slide

  55. PROFIT!

    View Slide

  56. WHAT HAPPENS THEN?

    View Slide

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

    View Slide

  58. 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

    View Slide

  59. WHAT KEY CHALLENGES DO
    INTEGRATORS FACE WHEN WORKING
    WITH PULL REQUESTS?
    Å
    http://www.gousios.gr/blog/How-do-project-owners-use-pull-requests-on-Github/

    View Slide

  60. View Slide

  61. HOW TO OPEN SOURCE?

    View Slide

  62. LICENSE

    View Slide

  63. NO LICENSE ==
    ALL RIGHTS RESERVED ©
    Å https://github.com/blog/1964-license-usage-on-github-com

    View Slide

  64. Å TLDRLEGAL.COM

    View Slide

  65. Å CHOOSEALICENSE.COM

    View Slide

  66. THE README FILE

    View Slide

  67. project-x
    =========
    project-x is a better way to achieve this and that, by leveraging the new
    API, bla bla bla.
    ## Usage
    ...
    ## Installation
    ...
    ## Requirements
    ...
    ## Contributing
    See CONTRIBUTING file.
    README example 1/2

    View Slide

  68. ## Running the Tests
    ...
    ## Credits
    ...
    ## Contributor Code of Conduct
    Please note that this project is released with a [Contributor Code of
    Conduct](http://contributor-covenant.org/). By participating in this project
    you agree to abide by its terms. See CODE_OF_CONDUCT file.
    ## License
    project-x is released under the MIT License. See the bundled LICENSE file for
    details.
    README example 2/2

    View Slide

  69. THE CONTRIBUTING FILE

    View Slide

  70. Also, checkout !
    Atom's one

    View Slide

  71. THE CODE_OF_CONDUCT FILE

    View Slide

  72. Å CONTRIBUTOR-COVENANT.ORG

    View Slide

  73. WRITE TESTS & AUTOMATE

    View Slide

  74. BE STANDARD

    View Slide

  75. ATTITUDE

    View Slide

  76. View Slide

  77. COMMUNICATION IS KEY!

    View Slide

  78. HIRE PEOPLE

    View Slide

  79. All of this can be applied to your "internal" projects too ė

    View Slide

  80. ONE MORE THING

    View Slide

  81. Open Source is more than
    making code available for free.

    View Slide

  82. It is a lot of work!

    View Slide

  83. Care about the people first.

    View Slide

  84. Communication is essential!

    View Slide

  85. Everyone can contribute!
    Å Your First PR

    View Slide

  86. Open Source is more than
    downloading code available for free.

    View Slide

  87. Give, don't (only) take.

    View Slide

  88. There are people behind Open Source projects.

    View Slide

  89. Money is still an issue in OSS...
    Å
    https://coderanger.net/funding-foss/

    View Slide

  90. ...which is not the case in a company.

    View Slide

  91. THANK YOU.
    QUESTIONS?
    ¾
    ®
    ¬
    Â
    williamdurand.fr
    github.com/willdurand
    twitter.com/couac
    TailorDev SAS

    View Slide

  92. LINKS
    http://williamdurand.fr/2013/07/04/on-open-sourcing-libraries/
    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
    https://github.com/blog/1530-choosing-an-open-source-license
    https://help.github.com/articles/open-source-licensing/
    http://www.codinghorror.com/blog/2007/04/pick-a-license-any-license.html
    https://medium.com/code-zen/how-to-maintain-a-successful-open-source-project-
    aaa2a5437d3a
    http://ryanbigg.com/2015/11/open-source-work/
    https://robots.thoughtbot.com/git-bisect
    https://git-scm.com/book/en/v2/Git-Tools-Debugging-with-Git
    https://git-scm.com/docs/git-archive
    http://writing.jan.io/2015/11/20/sustainable-open-source.html

    View Slide