Git & e git beginner workshop

667 views
544 views

Published on

Workshop Git for EclipseCon France 2013

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
667
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Git & e git beginner workshop

  1. 1. Git & EGit beginner Workshop Learn Git with Eclipse EclipseCon France 5 June 2013 Matthias Sohn Vincent Lalanne Igor Laborie
  2. 2. The team Vincent Lalanne Software Engineer at AKKA Matthias Sohn Product Owner at SAP Igor Laborie Software Architect at AKKA Git enthusiast
  3. 3. The Raspberry Pi ● ● ● ● ● ● ● ARM processor 700 Mhz RAM: 512Mb HDMI, Composite Ethernet 2 USB port SD Card 26 Pins http://www.raspberrypi.org/ http://elinux.org/RPi_Hub Model A ~22 € Model B ~33 €
  4. 4. Prepare to exercices RaspberryPi : PiGit / EclipseCon Or get EGit-Workshop.zip from an USB stick => Open index.html with a modern browser You need an EGit version > v2.2.0 => Install Eclipse Java Juno SR2 if needed. Exercises are also available at http://ilaborie. github.io/Git--EGit-beginner-workshop
  5. 5. Agenda ● ● ● ● ● Introducing Git Working locally Branches Remotes Exam ○ => Win a RaspberryPi B !
  6. 6. Introducing Git Git, JGit and EGit
  7. 7. VCS A Version Control System ● record changes ● retrieve a previous version ● provide collaborative works Like SVN, CVS, ClearCase, ...
  8. 8. CVCS Computer A Central VCS Server Checkout Version Database File Version 3 Computer B Version 2 Checkout File Version 1
  9. 9. DVCS Server Computer Version Database Computer A Version 3 File Computer B File Version 2 Version Database Version Database Version 1 Version 3 Version 3 Version 2 Version 2 Version 1 Version 1
  10. 10. Git ● ● ● ● ● ● easier offline usage easier to fork and merge (branches) speed scalability a lot of workflow ... Git is developer-friendly. Flexibility (with Workflow) is industry-friendly.
  11. 11. JGit & EGit JGit is a (partial) implementation of Git ● lightweight, ● pure Java library, ● modular (OSGi-ready) EGit is the Eclipse team provider for Git ● implemented on top of JGit ● Gerrit support ● Github support
  12. 12. Exercises 1 & 2 1 - Installation & Configuration ● http://192.168.42.1/exo1.html ● USB Stick: exo1.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo1.html 2 - Create Repositories ● http://192.168.42.1/exo2.html ● USB Stick: exo2.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo2.html
  13. 13. Notes ● Hierarchical configuration level: ○ system ○ user ○ project ● Authentication with Private/Public SSH keys
  14. 14. Working Locally Basic operations
  15. 15. Commit A commit just stores modifications (version) into the repository (local). Be careful, make significant commits to provide a beautiful history.
  16. 16. The Staging Area / Index ● Intermediate zone between the working directory and the repository. ● Useful to prepare commit. ● Can be skipped.
  17. 17. File status into Git ? ● A file can be untracked - not managed by the repository tracked - managed by the repository ● A tracked file can be unmodified if = last commit modified if ≠ staging area * staged if ≠ last commit & = staging area *
  18. 18. Add Never Tracked Files Working Directory Staging Area ? add * * Repository
  19. 19. Remove Untracked Files Working Directory Staging Area remove Repository
  20. 20. Move Never Tracked Files Working Directory Staging Area move Repository
  21. 21. Ignore Never Tracked Files Working Directory ignore ? Staging Area Repository
  22. 22. Commit Never Tracked Files Working Directory Staging Area commit * Repository
  23. 23. Exercices 3 & 4 3 - Basic Operations ● http://192.168.42.1/exo3.html ● USB Stick: exo3.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo3.html 4 - Playing with Diffs (optional) ● http://192.168.42.1/exo4.html ● USB Stick: exo4.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo4.html
  24. 24. Notes ● It's easy to modify the last commit (amend) But Don't modify a shared commit ! ● Reset allows you to unstage (and more)
  25. 25. Branches The DAG
  26. 26. Git Objects 98ca9.. commit size tree 92ec2 author Igor committer Igor parents ce23a1 First commit of my project 5b1d3.. 92ec2.. tree size blob 5b1d3 README.md blob 911e7 cba0a index.html size README === LICENSE blob blob 911e7.. blob size Eclipse Public License cba0a.. ce23a1.. commit ... size blob size <html> <head> <title>Index
  27. 27. The Directed Acyclic Graph c4 c0 c1 c2 c5 c6 c3 c11 c7 c8 c9 c10 c12
  28. 28. Branches fe at ur e_ B c2 c3 c11 c9 How many commits in feature A ? c10 re c8 fe atu c7 c12 ma ste r c1 c6 _A c0 c5 HEAD c4
  29. 29. Create a new branch: feature_A master c0 c1 c2 c3
  30. 30. Create a new branch: feature_A master c1 c2 c3 feature_A c0
  31. 31. Create a new branch: feature_A master c1 c2 c3 feature_A c0
  32. 32. Implementing the feature A master c1 c2 c3 feature_A c0
  33. 33. Implementing the feature A master c1 c2 c3 c4 feature_A c0
  34. 34. Implementing the feature A master c1 c2 c3 c4 c5 feature_A c0
  35. 35. Checkout to master master c1 c2 c3 c4 c5 feature_A c0
  36. 36. Checkout to master master c1 c2 c3 c4 c5 feature_A c0
  37. 37. Working on master master c1 c2 c3 c4 c5 feature_A c0
  38. 38. Working on master master c6 c1 c2 c3 c4 c5 feature_A c0
  39. 39. Working on master master c6 c1 c2 c4 c5 c3 feature_A c0 c7
  40. 40. Create a new branch: feature_B master c6 c1 c2 c4 c5 c3 feature_A c0 c7
  41. 41. Create a new branch: feature_B B e_ master ur at fe c6 c1 c2 c4 c5 c3 feature_A c0 c7
  42. 42. Implementing the feature B B e_ master ur at fe c6 c1 c2 c4 c5 c3 feature_A c0 c7
  43. 43. Implementing the feature B master c1 c2 c7 c8 c4 c5 c3 feature_A c0 feature_B c6
  44. 44. Implementing the feature B feature_B master c6 c1 c2 c4 c5 c3 feature_A c0 c7 c8 c9
  45. 45. Step back to master feature_B master c6 c1 c2 c4 c5 c3 feature_A c0 c7 c8 c9
  46. 46. Step back to master feature_B master c6 c1 c2 c4 c5 c3 feature_A c0 c7 c8 c9
  47. 47. Let's merge master with feature_A feature_B master c6 c1 c2 c4 c5 c3 feature_A c0 c7 c8 c9
  48. 48. Let's merge master with feature_A feature_B c8 c6 c2 c3 c10 c4 c5 master c1 feature_A c0 c7 c9
  49. 49. Go to feature_B feature_B c8 c6 c2 c3 c10 c4 c5 master c1 feature_A c0 c7 c9
  50. 50. Go to feature_B feature_B c8 c6 c2 c3 c10 c4 c5 master c1 feature_A c0 c7 c9
  51. 51. Let's rebase on master feature_B c8 c6 c2 c3 c10 c4 c5 master c1 feature_A c0 c7 c9
  52. 52. Let's rebase on master feature_B c8 c10 c1 c2 c3 c4 c5 feature_A c0 c8' c7 master c6 c9
  53. 53. Let's rebase on master feature_B c8 c10 c1 c2 c3 c4 c5 feature_A c0 c8' c7 master c6 c9 c9'
  54. 54. Let's rebase on master c8 c2 c3 c4 c8' c9' c5 master c1 c7 feature_A c0 feature_B c10 c6 c9
  55. 55. Let's rebase on master c8 c2 c3 c4 c8' c9' c5 master c1 c7 feature_A c0 feature_B c10 c6 c9
  56. 56. Merge vs Rebase c6 c1 c2 c3 c10 feature_A c5 c8 c6 c3 c11 c10 c4 c5 master c2 feature_A c1 c9 feature_B c0 c7 c9' feature_B c4 c8' master c0 c7
  57. 57. Exercices 5 & 6 5 - Branches Workflow ● http://192.168.42.1/exo5.html ● USB Stick: exo5.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo5.html 6 - Handle Conflicts (Optional) ● http://192.168.42.1/exo6.html ● USB Stick: exo6.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo6.html
  58. 58. Notes ● Tag is a reference on a commit ● SHA-1 allow integrity check (fsck) ● Git rarely deletes data, reflog could save your life
  59. 59. Remotes Sharing
  60. 60. Remotes A remote repositories is defined by ● an alias, ● an URL ssh:// http:// https:// file:// git://
  61. 61. Initially Remote master c0 Local
  62. 62. Clone Remote Local c0 master origin/master master c0
  63. 63. A Local Commit Remote Local c0 master origin/master master c0 c1
  64. 64. A Remote Commit Remote Local c2 c0 master origin/master master c0 c1
  65. 65. Fetch Remote Local master c1 c2 c0 origin/master c2 master c0
  66. 66. Pull Remote Local master c1 c2 c0 c3 origin/master c2 master c0
  67. 67. Push Remote Local master c1 c3 c3 c2 master c2 c0 origin/master c0 c1
  68. 68. Exercices 7 & 8 7 - Clone Repository ● http://192.168.42.1/exo7.html ● USB Stick: exo7.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo7.html 8 - Remote Workflow ● http://192.168.42.1/exo8.html ● USB Stick: exo8.html ● http://ilaborie.github.io/Git--EGit-beginnerworkshop/exo8.html
  69. 69. Notes ● Blame show commit details for each line of a file (Annotation) ● Branch tracking ● Upstream
  70. 70. Exam http://git-quizz.herokuapp.com/
  71. 71. Thanks Question(s)

×