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

Git & GitHub & OpenSource (LavaJUG)

Git & GitHub & OpenSource (LavaJUG)

Vous n'en avez peut-être pas conscience mais beaucoup de technologies sont Open Source, c'est-à-dire que des gens (et des entreprises) prennent du temps pour collaborer ensemble sur des projets ouverts.

Grâce à Git (un outil de gestion de versions) et surtout à GitHub (une plateforme collaborative faisant la promotion de l'Open Source et s'appuyant sur Git), l'Open Source s'est démocratisé et tout le monde peut contribuer à un monde meilleur.

Dans cette présentation, vous entendrez parler de Git avec des astuces pour travailler efficacement. Je vous parlerai de GitHub (et GitLab) pour collaborer sur des projets existants et/ou nouveaux, que vous soyez une grande société, une startup ou simplement une personne voulant apporter sa pierre à l'édifice. Je vous donnerai des clés pour mettre le pied à l'étrier et vous faire comprendre que, vraiment, tout le monde peut contribuer et que c'est une bonne chose.

Nous discuterons de l'Open Source en entreprise et comment reverser des contributions à la communauté : apprendre à donner plutôt que seulement prendre.

Pour terminer, j'évoquerai mes 4 dernières années en tant que "mainteneur" de projets Open Source, avec ce qu'il faut faire et ne pas faire, ainsi que différents exemples.

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 26, 2015
Tweet

More Decks by William Durand

Other Decks in Programming

Transcript

  1. 1

  2. 3

  3. git config --global help.autocorrect 1 git lol WARNING: You called

    a Git command named 'lol', which does not exist. Continuing under the assumption that you meant 'log' in 0.1 seconds automatically... commit 2feb149c8e76d12848f7535a8eb4d51b1c225776 Author: William Durand <[email protected]> Date: Mon Nov 16 14:54:53 2015 +0100 add badges ... 5 . 2
  4. GIT ARCHIVE git archive --format zip -o snapshot.zip HEAD git

    archive --format tar --prefix myapp/ <commit> | (cd /tmp && tar xf -) 5 . 4
  5. git config --global rerere.enabled true git merge master Auto-merging index.html

    CONFLICT (content): Merge conflict in index.html Recorded preimage for 'index.html' Automatic merge failed; fix conflicts and then commit the result. git commit --no-edit Recorded resolution for 'index.html' [old-branch abcd123] Merge branch 'master' into old-branch git merge master Auto-merging index.html CONFLICT (content): Merge conflict in index.html Resolved 'index.html' using previous resolution. 5 . 5
  6. GIT BISECT git bisect start git bisect good abcd123 git

    bisect bad [badd123] # The script should end with a non-zero return status when it fails git bisect run mvn clean test 5 . 6
  7. git rebase -i HEAD~<number of commits> pick d1ed4e4 Fix typo

    pick b49cb42 Update for lavajug pick e35510f Add new images # Rebase 5f167bb..e35510f onto 5f167bb (3 command(s)) # # 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 6 . 3
  8. 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,?]? 6 . 5
  9. merge cherry-pick rebase git checkout - Switched to branch 'master'

    git checkout - Switched to branch 'feat-undefined-variable' 6 . 7
  10. git format-patch master --stdout > fix-undefined-variable.patch From: William Durand <[email protected]>

    Date: Thu, 13 Nov 2015 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 7 . 2
  11. git apply --stat fix-undefined-variable.patch test.js | 2 +- 1 file

    changed, 1 insertion(+), 1 deletion(-) 7 . 3
  12. patch -p1 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 2015 +0100 Fix undefined variable Signed-off-by: William Durand <[email protected]> 7 . 5
  13. git browse # open https://github.com/random/repo git browse -- issues #

    open https://github.com/random/repo/issues 9 . 3
  14. 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 9 . 5
  15. 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. 13 . 8
  16. 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 13 . 12
  17. 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. 15 . 7
  18. ## 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. 15 . 8
  19. git commit -m "Prepare X.Y.Z release" git tag vX.Y.Z gem

    build Z++ git commit -m "Bump version to X.Y.Z+1-dev" git push origin master --tags gem push 16 . 4
  20. 19

  21. 20