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

Enterprise Web App. Development (2): Version Control Tool Training

Enterprise Web App. Development (2): Version Control Tool Training

This is the second course of a series of the courses for Enterprise Web Application development based on several Open Source products. As open source development tools, we are going to take care of Apache Maven as a build tool, Git as a version control tool and JUnit5 as a test tool. After then, we are going into the Jakarta EE framework. Therefore this series require the basic skills of Windows 10, CentOS, Eclipse IDE, Java SE (Oracle JDK, Open JDK), Payara Server and PostgreSQL. Regarding the Payara Server, we can use another Web Application Server conforming to Jakarta EE specification. As for PostgreSQL, we might be able to use another RDBMS product instead. We can also make use of another Linux distribution instead of CentOS.

E7d0d73badb1cc1df2bc44f58d51aaff?s=128

Koichi NAKAGAWA

November 26, 2020
Tweet

Transcript

  1. VERSION CONTROL TOOL A part of the Open Source Development

    Tools Using Git™ with EGit™ Eclipse™ Plug-in 1 By Koichi NAKAGAWA
  2. Open Source Development Tools Version Control Tool (Git™) 2

  3. EWA development course curriculum Object Oriented Development Methodology JSF with

    CDI JPA + JTA with CDI JAX-RS Application Architecture Design Patterns Eclipse IDE™ Version Control Tool with Git™ Build Tool with Apache Maven™ Payara Server™ Administration Windows 10™ + Linux (CentOS™) Total EWA Development Exercise Jakarta Batch Java SE (Oracle JDK™/OpenJDK™) Required Skills to take courses Test Tool with JUnit5 PostgreSQL™ Administration 3
  4. Open Source Development Tools • Build Tool (Apache Maven™ with

    Eclipse™ Plug-in) • Version Control Tool (Git™ with Eclipse™ Plug-in) • Test Tool (JUnit5 with Eclipse™ Plug-in) 4
  5. Trademarks Notice • Git™ and the Git™ logo( ) are

    either registered trademarks or trademarks of Software Freedom Conservancy, Inc., corporate home of the Git Project, in the United States and/or other countries. • Apache™ Subversion® and the Apache™ Subversion® logo( ) are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.. • Eclipse IDE for Enterprise Java Developers™, the Eclipse IDE for Enterprise Java Developers™ logo( ) are trademarks of the Eclipse Foundation. • Eclipse GitTeam Provider™, Eclipse EGit™, EGit™ is trademark of the Eclipse Foundation. • Java™ is trademark of Oracle Corporation. 5
  6. Assumption for this course • The trainees who take this

    course are required the following skills in advance • Oracle JDK/OpenJDK (Version: 8) • Eclipse IDE for Enterprise Java Developers (Version: 2020-09 (4.17.0)) • Build Tool Training Course 6
  7. Objectives for this course • Learning the Git™ Version Control

    Tool, you will obtain the concepts of version control tool and how to operate it through EGit™ Eclipse™ plug-in for Git™. Additionally you will know how to set up the Git™ remote and local repositories. 7
  8. Git™ Version Control Tool • Git™ Concepts • How to

    set up Git™ and its Repositories • How to use EGit™ Eclipse Plug-in 8
  9. Git™ Concepts 9

  10. Open Source Version Control Tools History • Historical Version Control

    Tools RCS Open-source, Local data model based version control system managing versions for each file. => Developers manage versions of their own files. Apache™ Subversion® Open-source, Centralized version control system managing versions for each file. => Developers use a shared single repository. Git™ Open-source, Distributed version control system managing versions for whole project files. => Faster to commit, No single point failure, available Offline. 10
  11. Commit and Version Product.java (Ver.1) Product.java (Ver.2) Product.java (Ver.3) .

    . . Commit Commit Commit Local Repository Developer’s PC • Git™ – Source Code Management (SCM) -Version Control 11
  12. Versioning Unit • Git™ –Versioning for a whole project src

    main java resources webapp site test java resources Project X Local Repository 1. Commit for a whole project X 2. An ID is assigned for a whole project 3. Retrieve a whole project X by ID 12
  13. Tag feature • Git™ –Tag for a specific ID Project

    X Local Repository 1. Assign a tag for a specific ID 2. The tag is mapped to the ID 3. Retrieve a whole project X by tag ID:47834 ID:48342 ID:82349 ID:13843 ID:43589 COMMIT COMMIT COMMIT COMMIT COMMIT TAG TAG Rel. 1 Rel. 2 13
  14. Branch feature • Git™ – Branch (1) ID:47834 ID:48342 ID:82349

    ID:13843 ID:43589 ID:7364 ID:23442 ID:91349 New Branch Merge Branches “XYZ” Branch “ABC” Branch 14
  15. Branch feature • Git™ – Branch (2) “master” branch “develop”

    branch “special” branch “hotfix” branch 15
  16. Git™ Repositories • Git™ Repositories and Communications between Git™ Clients

    and Server Git™ Client PC Git™ Server Remote Repository Local Repository Git™ Client PC Local Repository . . . Server Push Pull Push Pull Access + Commit Access + Commit 16
  17. Team Development • Each member of Development Team communicates with

    Git™ Server Development Team Member A1 Development Team Member A2 Development Team Member A3 Git™ Server Remote Repository Server push push pull pull pull - Source/Resource files push Development Team A Repository xxx Project for xxx.jar 17
  18. Team Development • Development Teams communicate with Git™ Server Git™

    Server Remote Repository Server push push pull pull pull push Development Team A Development Team B Development Team C Depend Depend Project for zzz.war Project for yyy.jar Project for xxx.jar Repository xxx yyy zzz 18
  19. How to set up Git™ and its Repositories 19

  20. EGit™ • EGit™(Git Plug-in for Eclipse) EGit™ is a Git

    Plug-in for Eclipse and bundled into Eclipse IDE for Enterprise Java Developers™ 20
  21. • Configure some items of EGit™ How to configure EGit™

    Set Operator’s Name and Email address Generate RSA Key for SSH communication Choose “Committing” Dialog Menu’s Type 21
  22. • Configuration Example of EGit™ How to configure EGit™ Configuration

    Item Configuration Value Set Operator’s Name and Email address user.name: “TaroYamada” user.email: “xxxx@xyz.com” Change Committing Dialog Menu’s Type Change from “Staging View” to “Commit Dialog” Generate RSA Key for SSH communication Generate RSA Key providing any “Passphrase” 22 Exercise: Let’s configure EGit™ with the above information.
  23. • Set Operator’s Name to “Taro Yamada” and Email address

    to “xxxx@xyz.com” From “Window” menu, Select “Preferences”  “Team”  “Git”  “Configuration” How to configure EGit™ Fill in correct email and name Set Operator’s Name and Email address 23 Key Value user.name Taro Yamada user.email xxx@xyz.com
  24. • Generate RSA Key for SSH communication From “Window” menu,

    Select Preferences  General  Network Connectivity  SSH2 How to configure EGit™  Click “Key Management” tab.  Click “Generate RSA Key …” button.  Enter “Passphrase” and “Confirm passphrase” and click “Apply and Close” button.  If eclipse asked you if you want to create “.ssh” folder, please click “Yes” button. Generate RSA Key for SSH communication 24
  25. • Choose “Staging View” or “Commit Dialog” for “Committing” Dialog

    Menu From “Window” menu, Select “Preferences”  “Team”  “Git”  “Committing” How to configure EGit™ Check or Uncheck Choose “Committing” Dialog Menu’s Type 25
  26. Eclipse IDE for Enterprise Java Developer™ EGit™ Plug-in and Git™

    Server • EGit™: Eclipse Git Plug-in + Git™ Server EGit™ PC Git™ Server Remote Repository Local Repository Eclipse IDE for Enterprise Java Developer™ EGit™ PC Local Repository . . Server Push Pull Push Pull Access + Commit Access + Commit SSH, HTTP, etc. 26
  27. How to set up Git™ and its Repository? • Procedures

    to set up Git™ and its Repository Set-up of Git™ Server Set-up of Git™ “bare” Remote Repository Set-up of Git™ Repositories with EGit™ 27
  28. How to set up Git™ and its Repository? • Procedure

    to set up the Git™ Server (1) Install Git™ product on CentOS 8 (2) Check firewall configuration for SSH communication and change it, if needed Set-up of Git™ Server CentOS 8 Git™ Product SSH (2)Configure Firewall for SSH service, if needed firewalld (1) Install Git™ product 28
  29. How to set up Git™ and its Repository? • How

    to set up Git™ Server 1. Install Git product on CentOS 8 #dnf -y install git 2. Check whether “ssh” service is included as an allowed service to firewall # firewall-cmd --list-all public (default, active) interfaces: ens32 sources: services: dhcpv6-client ports: masquerade: no forward-ports: icmp-blocks: rich rules: 3. (Option) If there is no SSH listed, configure firewall to include “ssh” service as an allowed service # firewall-cmd --add-service=ssh --runtime-to-permanent Procedure to install Git™ product on CentOS 8 and check & set firewall configuration Set-up of Git™ Server Check if there is SSH service 29
  30. How to set up Git™ and its Repository? • Example

    of Set-up of Git™ Server (1) Install Git™ product on CentOS 8. (2) As there is no firewall configuration for SSH communication, configure it. Set-up of Git™ Server CentOS 8 Git™ Product SSH (2)Configure Firewall for SSH service, as Firewall is not configured for SSH service (1) Install Git™ product firewalld 30 Exercise: Let’s set up Git™ Server with the above information.
  31. How to set up Git™ and its Repository? • How

    to set up Git™ Server 1. Install Git product on CentOS 8 #yum -y install git 2. Check whether “ssh” service is included as an allowed service to firewall # firewall-cmd --list-all public (default, active) interfaces: ens32 sources: services: dhcpv6-client ports: masquerade: no forward-ports: icmp-blocks: rich rules: 3. As there is no SSH listed, configure firewall to include “ssh” service as an allowed service # firewall-cmd --add-service=ssh --runtime-to-permanent Procedure to install Git™ product on CentOS 8 and check firewall configuration Set-up of Git™ Server 31
  32. How to set up Git™ and its Repository? • Example

    of Git™ “bare” Remote Repository on Git™ Server (1) Create Git™ User on Git™ Server (2) Create “bare” Git™ repository on Git™ Server Set-up of Git™ “bare” Remote Repository CentOS 8 Git™ Product SSH Git™ “bare” Remote Repository Git™ User firewalld 32
  33. How to set up Git™ and its Repository? • How

    to make Git™ “bare” Remote Repository on Git™ Server 1. Create an Git User and set Password for the user (These Git User and Password are used to configure EGit™ later) #useradd [Git User] #passwd [Git User] 2. Create Git “bare” Repository #mkdir [Repository top folder] #cd [Repository top folder] #git init --bare [Repository name]  Git™ “bare” Repository folder is created #cd .. #chown -R [Git User]:[Git Group] [Repository top folder]  Change the owner of Git™ folders and files Procedure to make Git™ “bare” Remote Repository on Git™ Server Set-up of Git™ “bare” Remote Repository 33
  34. How to set up Git™ and its Repository? • Example

    of Git™ “bare” Remote Repository on Git™ Server (1) Create “git” as a Git™ User in CentOS8. (2) Create Git™ “bare” Repository named “projects.git” under “/var/lib/git” folder. Set-up of Git™ “bare” Remote Repository CentOS 8 Git™ Product SSH Git™ “bare” Repository: “/var/lib/git/projects.git” Git™ User: “git” firewalld 34 Exercise: Let’s set up Git™ “bare” Remote Repository with the above information.
  35. How to set up Git™ and its Repository? • How

    to make Git™ “bare” Remote Repository on Git™ Server 1. Create an Git User and set Password for the user (These Git User and Password are used to configure EGit™ later) #useradd git #passwd git  Keep in mind the password you set here. 2. Create Git “bare” Repository #mkdir /var/lib/git #cd /var/lib/git #git init --bare projects.git #cd .. #chown -R git:git git Procedure to make Git™ “bare” Remote Repository on CentOS 8 Set-up of Git™ “bare” Remote Repository 35
  36. How to set up Git™ and its Repository? • How

    to configure Eclipse™ for Git™ Remote/Local Repositories with EGit™ Typical 3 ways to configure Eclipse™ for Git™ Repositories with EGit™ (Eclipse™ Git Plug-in) Set-up of Git™ Repositories with EGit™ Typical 3 ways to configure Eclipse™ with EGit™ 1. Create a new project to Git™ Repositories from scratch 2. Import a project existing in Git™ Remote repository 3. Add a new project to existing Git™ Repositories Repository xxx yyy zzz Add a new project 36
  37. How to set up Git™ and its Repository? • How

    to set up Git™ Repositories for a Eclipse project of “projectX” with EGit™ 3 Ways to set up Git™ Repositories with EGit™ Eclipse™ Plug-in on Eclipse™ 1. Create new Git™ Repositories for a project 2. Import a project existing in Git™ Remote repository 3. Add a project to existing Git™ Repositories Not Existed /projects.git Local Repository Remote Repository Not Existed /projects.git/ projectX /repository/ projectA /projects.git/ projectA Only the bare repository is created. Set-up of Git™ Repositories with EGit™ /repository/ projectX /ws1/ projectX /projects.git/ projectX /projects.git/ projectX /repository2/ projectX /repository/ projectA projectX /ws1/ projectX /projects.git/ projectA projectX /ws2/ projectX 37
  38. How to set up Git™ and its Repository? • Step1:

    Convert an Eclipse™ project into a Git™ managed project on the “master” branch in Local Repository • Step2: Commit the Git™ managed project on the Local “master” branch • Step3: Push the committed Git™ project on the Local “master” branch to Remote Repository • Step4: Configure Fetch/Push From/To Upstream 1. Create new Git™ Repositories for a project (Summary) Not Existed /projects.git Local Repository Remote Repository /repository/ projectX /projects.git/ projectX /projects.git/ projectX Set-up of Git™ Repositories with EGit™ /ws1/ projectX Only the bare repository is created. /repository/ projectX /repository/ projectX /repository/ projectX 38
  39. How to set up Git™ and its Repository? • Sample

    to set up Git™ Repositories for a new Eclipse project of “simple” with EGit™ 1. Create new Git™ Repositories for a project (Exercise) Not Existed /projects.git Local Repository Remote Repository Only the bare repository is created. Set-up of Git™ Repositories with EGit™ /repository/ simple /ws1/ simple /projects.git/ simple “master” branch Git™ Server IP: 192.168.56.101 Git Folder: /var/lib/git Git User: git Eclipse Workspace Folder: “ws1” “master” branch in Local Repository Git Folder: C:\Users\<UserId>\git 39 Exercise: Let’s create a new project to Git™ Repositories from scratch with the above information.
  40. How to set up Git™ and its Repository? a. (Step

    1) Convert an Eclipse project into a Git™ managed project on the “master” branch in Local Repository - In Project Explorer, right click on project  Team  Share Project … - Click “Create …” button next to Repository field. - Enter a repository folder of “C:\Users\<UserId>\git\repository” and click “Finish” button twice. b. (Step 2) Commit the Git™ managed project on the Local “master” branch for the first time - In Project Explorer, right click on project  Team  Commit … - Fill in the “Commit Message” field and click “Commit” button. c. (Step 3) Push the local “master” branch to the remote repository - In Project Explorer, right click on project  Team  Push Branch ‘master’ … - Enter “origin” in Remote name field. Enter “ssh://git@192.168.56.101/var/lib/git/projects.git” in URI field. And Enter password for git user. And click the checkbox of Store in Secure Store. Then click “Preview >” button. - Confirm that “master” is set in the branch name field and the checkbox of “Configure upstream for push and pull” is checked and the pull down menu of “When pulling” is set to “Merge”. Then click “Preview >” button. - Confirm that the expected push result is “master  master [new branch]” and click “Push” button. Once the confirmation dialog appears, check it and click “Close” button. 1. Create new Git™ Repositories for a project (Operations Summary) Set-up of Git™ Repositories with EGit™ 40
  41. How to set up Git™ and its Repository? d. (Step

    4) Configure Push to Upstream - In Project Explorer, right click on the project  Team  Remote  Configure Push to Upstream… - Click “Advanced…” button and Click “Add All Branches Spec”, “Add All Tags Spec” buttons and confirm that the following two entries were added in the Specifications for push and enable “Force Update” for both entries and click “Finish” and “Save” button. - refs/heads/*:refs/heads/* - refs/tags/*:refs/tags/* e. (Step 4) Configure Fetch from Upstream - In Project Explorer, right click on the project  Team  Remote  Configure Fetch From Upstream… - Click “Advanced…” button and Click “Add All Tags Spec” buttons and confirm that the following entries were shown in the Specifications for fetch and enable “Force Update” for both entries and “Finish” and “Save” button. - refs/heads/*:refs/remotes/origin/* - refs/tags/*:refs/tags/* 1. Create new Git™ Repositories for a project (Operations Summary) Set-up of Git™ Repositories with EGit™ 41
  42. • Convert an Eclipse project into a project in Git™

    Local Repository In Project Explorer, right click on “simple” project  Team  Share Project … How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (1-1) Set-up of Git™ Repositories with EGit™ 42
  43. • Convert an Eclipse project into a project on the

    “master” branch in Git™ Local Repository Click “Create …” button next to Repository field on “Configure Git Repository” dialog screen. Enter or select a Local Repository directory like “C:\Users\<UserId>\git\repository” and click “Finish” button on “Create a New Repository” dialog screen. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (1-2) Set-up of Git™ Repositories with EGit™ 43
  44. • Convert an Eclipse project into a project on the

    “master” branch in Git™ Local Repository Confirm the result and click “Finish” button on “Configure Git Repository” dialog screen. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (1-3) Set-up of Git™ Repositories with EGit™ 44
  45. • Commit the project for the first time In Project

    Explorer, confirm the “>” mark next to the “simple” project In Project Explorer, right click on “simple” project Team  Commit … How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (2-1) Set-up of Git™ Repositories with EGit™ 45
  46. • Commit the project for the first time Click “

    ” icon for “Unstaged Changes” list to add all files as files to be committed in “Git Staging” pane screen. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project with “Staging View” (2-2-1-1) Set-up of Git™ Repositories with EGit™ 46
  47. • Commit the project for the first time Fill in

    the “Commit Message” field and click “Commit” button on “Git Staging” pane screen.  Confirm that “>” mark next to “simple” project is disappeared in the Project Explorer. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project with “Staging View” (2-2-1-2) Set-up of Git™ Repositories with EGit™ 47 Taro Yamada tyamada@aaa.bbb.com
  48. • Commit the project for the first time Fill in

    the “Commit Message” field and check all Git™ managed files and click “Commit” button on “Commit Changes” dialog screen. Confirm that “>” mark next to “simple” project is disappeared in Project Explorer. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project with “Commit Dialog” (2-2-2) Set-up of Git™ Repositories with EGit™ 48
  49. • Push the Local “master” branch to the remote repository

    In Project Explorer, right click on “simple” project  Team  Push Branch ‘master’ … How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (3-1) Set-up of Git™ Repositories with EGit™ 49
  50. • Push “master” branch to the remote repository Enter “origin”

    in Remote name field. Enter “ssh://git@192.168.56.101/var/lib/git/pr ojects.git” in URI field on “Destination Git Repository” dialog screen. And Enter password for git user. And click the checkbox of Store in Secure Store. Then click “Preview >” button. How to set up Git™ and its Repository? ssh://git@192.168.56.101/var/lib/git/projects.git 1. Create new Git™ Repositories for a project (3-2) Set-up of Git™ Repositories with EGit™ 50 192.168.56.101
  51. • Push “master” branch to the remote repository Select “master

    -> master [new branch]” and click “Push” button on “Push Confirmation” dialog screen. Once the “Push Results” dialog screen appears, check it and click “Close” button. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (3-3) Set-up of Git™ Repositories with EGit™ 51
  52. • Configure Push to Upstream In Project Explorer, right click

    on the “simple” project  Team  Remote  Configure Push to Upstream… How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (4-1) Set-up of Git™ Repositories with EGit™ 52
  53. • Configure Push to Upstream Click “Advanced…” button on “Configure

    push for remote ‘origin’” dialog screen. Click “Add All Branches Spec”, “Add All Tags Spec” buttons and confirm that the following two entries were added in the “Specifications for push”. -refs/heads/*:refs/heads/* -refs/tags/*:refs/tags/* Enable “Force Update” for both entries. Click “Finish” button on “Push Ref Specification” dialog screen. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (4-2) Set-up of Git™ Repositories with EGit™ 53
  54. • Configure Push to Upstream Confirm new list of “Ref

    mappings” on “Configure push for remote ‘origin’” dialog screen. -refs/heads/*:refs/heads/* -refs/tags/*:refs/tags/* Click “Save” button. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (4-3) Set-up of Git™ Repositories with EGit™ 54
  55. • Configure Fetch from Upstream In Project Explorer, right click

    on the “simple” project  Team  Remote  Configure Fetch from Upstream… How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (5-1) Set-up of Git™ Repositories with EGit™ 55
  56. • Configure Fetch from Upstream Click “Advanced…” button on “Configure

    fetch for remote ‘origin’” dialog screen. Click “Add All Tags Spec” buttons on “Fetch Ref Specification” dialog screen. Confirm that the following entries were shown in the Specifications for fetch. - refs/heads/*:refs/remotes/origin/* - refs/tags/*:refs/tags/* Enable “Force Update” for both entries. Click “Finish” button. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (5-2) Set-up of Git™ Repositories with EGit™ 56
  57. • Configure Fetch from Upstream Confirm new list of Ref

    mappings on “Configure fetch for remote ‘origin’” dialog screen - refs/heads/*:refs/remotes/origin/* - refs/tags/*:refs/tags/* Click “Save” button. How to set up Git™ and its Repository? 1. Create new Git™ Repositories for a project (5-3) Set-up of Git™ Repositories with EGit™ 57
  58. How to set up Git™ and its Repository? • Step1:

    Import from Remote Repository to Local Repository and Eclipse™ Workplace • Step2: Configure Fetch/Push From/To Upstream Not Existed /projects.git/ projectX Local Repository Remote Repository /repository2/ projectX /projects.git/ projectX 2. Import a project existing in Git™ Remote repository (Summary) /repository2/ projectX /projects.git/ projectX Set-up of Git™ Repositories with EGit™ /exercise2/ projectX 58
  59. How to set up Git™ and its Repository? • Sample

    to set up Git™ repositories for a Eclipse project of “simple” with EGit™ Local Repository Remote Repository Set-up of Git™ Repositories with EGit™ 2. Import a project existing in Git™ Remote repository (Exercise) Not Existed /projects.git/ simple /projects.git/ simple /repository2/ simple “master” branch “master” branch “master” branch in Local Repository /ws2/ simple Eclipse Workspace Folder: “ws2” Git™ Server IP: 192.168.56.101 Git Folder: /var/lib/git/ Git User: git Git Folder: C:\Users\<UserId>\git 59 Exercise: Let’s import a project existed in Git™ Remote Repositories with the above information.
  60. How to set up Git™ and its Repository? a. (Step

    1) Import an existing project from a remote repository into a newly created local repository folder - In Project Explorer, right click on project  Import…  Git  Projects from Git. Then click “Next >” button. - Select “Clone URI” and click “Next >” button. - Enter “ssh://git@192.168.56.101/var/lib/git/projects.git” in URI field. And Enter password for git user. And click the checkbox of Store in Secure Store. Then click “Next >” button. - Confirm “master” in Branch Selection menu and the checkboxes for it is checked. And click “Next >” button. - Confirm the local Git repository folder of “C:\Users\<UserId>\git\repository2” in the Directory field and “master” as Initial branch and “origin” as Remote name in Local Destination menu and click “Next >” button. - Confirm “Importing existing projects” is selected in Select a wizard to use for importing projects menu and click “Next >” button. - Confirm the target project is selected in Import Projects menu and click “Finish” button. 2. Import a project existing in Git™ Remote repository (Operations Summary) Set-up of Git™ Repositories with EGit™ 60
  61. How to set up Git™ and its Repository? b. (Step

    2) Configure Push to Upstream - In Project Explorer, right click on the project Team  Remote  Configure Push to Upstream… - Click “Advanced…” button and Click “Add All Branches Spec”, “Add All Tags Spec” buttons and confirm that the following two entries were added in the Specifications for push and enable “Force Update” for both entries and click “Finish” and “Save” button. - refs/heads/*:refs/heads/* - refs/tags/*:refs/tags/* c. (Step 2) Configure Fetch from Upstream - In Project Explorer, right click on the project Team  Remote  Configure Fetch From Upstream… - Click “Advanced…” button and Click “Add All Tags Spec” buttons and confirm that the following entries were shown in the Specifications for fetch and enable “Force Update” for both entries and “Finish” and “Save” button. - refs/heads/*:refs/remotes/origin/* - refs/tags/*:refs/tags/* 2. Import a project existing in Git™ Remote repository (Operations Summary) Set-up of Git™ Repositories with EGit™ 61
  62. • Create a new exercise work place named “ws2” 

    Click “File”  “Switch Workspace”  “Other…”  Fill in the new workspace folder path of “ws2” and click “Launch” button on “Select a directory as workspace” dialog screen. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (1) 62 C:\Users\<User Id>\eclipse-workspace\ws2 Set-up of Git™ Repositories with EGit™
  63. • Configure Installed JRE (1) 1. Select “Window  Preferences”

    and “Preferences” dialog screen comes up. 2. Select “Java  Installed JREs” and click “Add …” button on the dialog screen. How to set up Git™ and its Repository? 63 2. Import a project existing in Git™ Remote repository (2-1) Set-up of Git™ Repositories with EGit™
  64. • Configure Installed JRE (2) 3. Select “Standard VM” and

    click “Next >” button on “JRE Type” dialog screen. 4. Click “Directory …” button and select an installed JDK home directory on “JRE Definition” dialog screen. 5. Confirm the new list of “JRE system libraries” and click “Finish” button. How to set up Git™ and its Repository? 64 2. Import a project existing in Git™ Remote repository (2-2) Set-up of Git™ Repositories with EGit™
  65. • Configure Installed JRE (3) 5. Select the added JDK

    entry from “Installed JREs” on “Installed JREs” pane screen. 6. Click “Apply and Close” button. How to set up Git™ and its Repository? 65 2. Import a project existing in Git™ Remote repository (2-3) Set-up of Git™ Repositories with EGit™
  66. • Import an existing project in a remote repository In

    Project Explorer, click Import projects… How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-1) Set-up of Git™ Repositories with EGit™ 66
  67. • Import an existing project in a remote repository Git

     Projects from Git. Then click “Next >” button on “Select” dialog screen. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-2) Set-up of Git™ Repositories with EGit™ 67
  68. • Import an existing project in a remote repository Select

    “Clone URI” and click “Next >” button on “Select Repository Source” dialog screen. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-3) Set-up of Git™ Repositories with EGit™ 68
  69. • Import an existing project in a remote repository Enter

    “ssh://git@192.168.56.101 /var/lib/git/projects.git” in URI field. And Enter password for git user on “Source Git Repository” dialog screen and click the checkbox of Store in Secure Store. Click “Next >” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-4) Set-up of Git™ Repositories with EGit™ 69 192.168.56.101 ssh://git@192.168.56.101/var/lib/git/projects.git
  70. • Import an existing project in a remote repository Confirm

    “master” in “Branch Selection” dialog screen and the checkboxes for it is checked. Click “Next >” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-5) Set-up of Git™ Repositories with EGit™ 70
  71. • Import an existing project in a remote repository Confirm

    the Git Local Repository directory like “C:\Users\<UserId>\git\repository2” in the Directory field and “master” as Initial branch and “origin” as Remote name in “Local Destination” dialog screen. Click “Next >” button How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-6) Set-up of Git™ Repositories with EGit™ 71
  72. • Import an existing project in a remote repository Confirm

    “Importing existing projects” is selected in “Select a wizard to use for importing projects” dialog screen. Click “Next >” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-7) Set-up of Git™ Repositories with EGit™ 72
  73. • Import an existing project in a remote repository Confirm

    the target project is selected in “Import Projects” menu and click “Finish” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote repository (3-8) Set-up of Git™ Repositories with EGit™ 73
  74. • Configure Push to Upstream In Project Explorer, right click

    on the project  Team  Remote  Configure Push to Upstream… How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote Repository (4-1) Set-up of Git™ Repositories with EGit™ 74
  75. • Configure Push to Upstream  Click “Advanced…” button 

    comes up and click “Add All Branches Spec”, “Add All Tags Spec” buttons on “Push Ref Specification” dialog screen.  Confirm that the following two entries were added in the “Specifications for push”. -refs/heads/*:refs/heads/* -refs/tags/*:refs/tags/*  Enable “Force Update” for both entries and click “Finish”. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote Repository (4-2) Set-up of Git™ Repositories with EGit™ 75
  76. • Configure Push to Upstream  Confirm the new Ref.

    mappings on “Configure push for remote ‘origin’” dialog screen. -refs/heads/*:refs/heads/* -refs/tags/*:refs/tags/*  Click “Save and Push” button.  Confirm the push results on “Push Results” dialog screen.  Click “Close” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote Repository (4-3) Set-up of Git™ Repositories with EGit™ 76
  77. • Configure Fetch from Upstream In Project Explorer, right click

    on the project  Team  Remote  Configure Fetch from Upstream… How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote Repository (5-1) Set-up of Git™ Repositories with EGit™ 77
  78. • Configure Fetch from Upstream Click “Advanced…” button on “Configure

    fetch for remote ‘origin’” dialog screen. Click “Add All Tags Spec” button on “Fetch Ref Specification” dialog screen. Confirm that the following entries were shown in the Specifications for fetch. -refs/heads/*:refs/heads/* -refs/tags/*:refs/tags/* Enable “Force Update” for both entries. Click “Finish” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote Repository (5-2) Set-up of Git™ Repositories with EGit™ 78
  79. • Configure Fetch from Upstream  Confirm the new Ref.

    mappings on “Configure fetch for remote ‘origin’” dialog screen. -refs/heads/*:refs/heads/* -refs/tags/*:refs/tags/*  Click “Save” button. How to set up Git™ and its Repository? 2. Import a project existing in Git™ Remote Repository (5-3) Set-up of Git™ Repositories with EGit™ 79
  80. How to set up Git™ and its Repository? • Step1:

    Convert a Eclipse project into a Git™ managed project in the Local Repository • Step2: Push the project to Remote Repository /projects.git/ projectA Local Repository Remote Repository /repository/ projectA, projectX /projects.git/ projectA 3. Add a project to existing Git™ Repositories (Summary) /repository/ projectA /repository/ projectA, projectX /projects.git/ projectA, projectX Set-up of Git™ Repositories with EGit™ /exercise1/ projectX 80
  81. How to set up Git™ and its Repository? • Sample

    to set up Git™ repositories for a Eclipse project of “simple” with EGit™ Local Repository Remote Repository Set-up of Git™ Repositories with EGit™ 3. Add a project to existing Git™ Repositories (Exercise) /projects.git/ simple /repository/ simple “master” branch “master” branch /repository/ simple simple2 /ws1/ simple2 /projects.git/ simple simple2 “master” branch Eclipse Workspace Folder: “ws1” “master” branch in Local Repository Git™ Server IP: 192.168.56.101 Git Folder: /var/lib/git/ Git User: git Git Folder: C:\Users\<UserId>\git 81 Exercise: Let’s add a project to existing Git™ Repositories with the above information.
  82. How to set up Git™ and its Repository? a. (Step

    1) Convert a new project to a Git™ managed project under an existing Local Repository - In Project Explorer, right click on project Team  Share Project … - Click Drop-down button of Repository field and select an existing Local Repository - Select a repository folder of “C:\Users\<UserId>\git\repository” and click “Finish” button. b. (Step 2) Commit and Push the project to the Remote Repository - In Project Explorer, right click on project Team  Commit… - Fill in the “Commit Message” field and check all Git™ managed files and click “Commit” button. - Confirm the result of “Commit” and Click “Close” button. 3. Add a project to existing Git™ Repositories (Operations Summary) Set-up of Git™ Repositories with EGit™ 82
  83. • Switch the workplace back to “ws1” File  Switch

    Workspace  C:\Users\<User Id>\workspace\ws1 How to set up Git™ and its Repository? 3. Add a project to existing Git™ Repositories (1) Set-up of Git™ Repositories with EGit™ 83 ws1 ws2
  84. • Convert an Eclipse project into a Git™ managed project

    in the existing Local Repository In Project Explorer, right click on “simple2” project  Team  Share Project … How to set up Git™ and its Repository? 3. Add a project to existing Git™ Repositories (2-1) Set-up of Git™ Repositories with EGit™ 84
  85. • Convert an Eclipse project into a Git™ managed project

    in the existing Local Repository Click drop-down button of Repository field on “Configure Gir Repository” dialog screen and select an existing Local Repository like “C:\Users\<UserId>\git\repository\.git” Confirm the Target Location of the project “simple2” Click “Finish” button. Confirm the branch name of the Git™ managed project is “master” with the Project Explorer. How to set up Git™ and its Repository? 3. Add a project to existing Git™ Repositories (2-2) Set-up of Git™ Repositories with EGit™ 85
  86. • Push the Local Git managed project to the remote

    repository In Project Explorer, right click on “simple2” project  Team  Commit… How to set up Git™ and its Repository? 3. Add a project to existing Git™ Repositories (3-1) Set-up of Git™ Repositories with EGit™ 86
  87. • Commit the project for the first time Click “

    ” icon for “Unstaged Changes” list to add all files as files to be committed in “Git Staging” pane screen. How to set up Git™ and its Repository? Set-up of Git™ Repositories with EGit™ 87 3. Add a project to existing Git™ Repositories (3-2-1)
  88. • Commit the project for the first time Fill in

    the “Commit Message” field and click “Commit and Push” button on “Git Staging” pane screen. How to set up Git™ and its Repository? Set-up of Git™ Repositories with EGit™ 88 Taro Yamada tyamada@aaa.bbb.com 3. Add a project to existing Git™ Repositories (3-2-2)
  89. • Commit the project for the first time Confirm Push

    Results on “Pushed to repository - origin” dialog screen. Click “Close” button. Confirm that “>” mark next to “simple2” project is disappeared in Project Explorer. How to set up Git™ and its Repository? Set-up of Git™ Repositories with EGit™ 89 3. Add a project to existing Git™ Repositories (3-2-3)
  90. • Push the project to the remote repository  Fill

    in the “Commit Message” field on “Commit Changes to Git Repository” dialog screen.  Check all Git™ managed files.  Click “Commit and Push” button.  Confirm the Destination and click “Preview” button on “Push to branch in remote” dialog screen. How to set up Git™ and its Repository? 3. Add a project to existing Git™ Repositories (3-3-1) Set-up of Git™ Repositories with EGit™ 90 Second Commit
  91. • Push the project to the remote repository Confirm the

    expected Push result and click “Push” button on “Push Confirmation” dialog screen. Confirm the Push result and click “Close” button on “Pushed to ssh://…” dialog screen. Confirm that “>” mark next to “simple2” project is disappeared in Project Explorer. How to set up Git™ and its Repository? 3. Add a project to existing Git™ Repositories (3-3-2) Set-up of Git™ Repositories with EGit™ 91
  92. How to use EGit™ Eclipse Plug-in 92

  93. How to use EGit™? • Typical Operations with EGit™ on

    Eclipse 2020-06 (4.16.0) Commit Check Commit History Branch/Tag Pull/Push from/to Git™ Server Compare with Past Commit/Tag Checkout Past Commit/Tag 93
  94. Branch • Commit some modifications on a Branch How to

    use EGit™? Commit Branch Get Project(s) Commit Project(s) : Commit Points Finish Modification (HEAD) (NEW HEAD) Modify Source Files Modify Source Files 94
  95. • Commit some modifications on “master” Branch in the Local

    Repository How to use EGit™? Commit Committed Local Repository Branch: “master” /repository/ simple2 Modified App.java Committed App.java 95 Exercise: After modification of a Java source file, let’s commit it on the “master” branch in the Local Repository with the above information. /ws1/ simple2 Eclipse Workspace Folder: “ws1” Commit Modification
  96. • Modify App.java of simple2 project How to use EGit™?

    Commit Insert 96
  97. • Commit some modifications on “master” Branch in the Local

    Repository (1-1) In Project Explorer, right click on project  Team  Commit… How to use EGit™? Commit 97
  98. • Commit some modifications on “master” Branch in the Local

    Repository (1-2-1) Fill in the “Commit Message” field and check modified Git™ managed files and click “Commit” button. Confirm that the “>” mark next to the project “simple2” is disappeared and all the project has the up- arrow mark with a figure of one(1) next to the branch name is added. How to use EGit™? Commit Note: This operation commits only to the Local Repository. When you click “Commit and Push” button instead of “Commit”, Commit is done both to the Local Repository and the Remote Repository. 98 Change Message Using Staging View
  99. • Commit some modifications on “master” Branch in the Local

    Repository (1-2-2) Fill in the “Commit Message” field and check modified Git™ managed files and click “Commit” button. Confirm that the “>” mark next to the project “simple2” is disappeared and all the project has the up-arrow mark with a figure of one(1) next to the branch name is added. How to use EGit™? Commit Note: This operation commits only to the Local Repository. When you click “Commit and Push” button instead of “Commit”, Commit is done both to the Local Repository and the Remote Repository. 99 Using Commit Dialog
  100. • Commit Ids in Commit History (When, Who, Branches, Parent

    Id, Child Id, …) How to use EGit™? Check Commit History : Commit Ids (HEAD) Commit History Commit Commit Commit Commit (Branch A, C) 100 Commit (Branch B)
  101. • Check Commit History of a project How to use

    EGit™? Local Repository Branch: “master” /repository/ simple2 Check Commit History Id: 1b692a3 Id: f87dfaa 101 Exercise: Let’s check Commit History of the project “simple2”. Remote Repository Remote Name: “origin” Branch: “master” /projects.git/ simple2 /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  102. • Check Commit History on “master” Branch in the Local

    Repository (1-1) In Project Explorer, right click on project  Team  Show in History How to use EGit™? Check Commit History 102
  103. • Check Commit History on “master” Branch in the Local

    Repository (1-2) In “History” pane, “Commit History” is shown How to use EGit™? Check Commit History Commit ID 103
  104. How to use EGit™? Branch/Tag “master” Branch “develop” Branch “special”

    Branch “hotfix” Branch 104
  105. • Local and Remote Branches How to use EGit™? Branch/Tag

    Local “A” Branch (HEAD) Commit Commit Remote “A” Branch Local Repository Remote Repository Synchronize Branch “A” <<General Rule>> • “Pull” once a day (Typically the first thing in the morning) • “Commit” + “Push” soon once Tests are passed. Push Pull Commit Push Pull Push Push Push 105
  106. • Check Local and Remote Branches in Commit History •

    Check Current Branch with Project Explorer How to use EGit™? Branch/Tag Local Repository Branch: “master” /repository/ simple2 /projects.git/ simple2 Remote Repository Remote Name: “origin” Branch: “master” Id: f87dfaa Id: 1b692a3 Id: 1b692a3 106 Exercise: Let’s check Commit History of the project “simple2” in Local and Remote Branches, and Current Branch with Project Explore. /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  107. • Check Local and Remote Branches in Commit History In

    “History” pane, confirm Local Branch and Remote Branch How to use EGit™? Local Branch Branch/Tag Remote Branch 107
  108. • Check Current Branch in Project Explorer In Project Explore,

    confirm Current Branch How to use EGit™? Branch/Tag Local Repository Directory Name Current Branch 1 Commit is ready for pushing to Upstream 108
  109. • Create New Branch (named “develop”) How to use EGit™?

    Branch/Tag “master” Branch “develop” Branch Id: f87dfaa /repository/ simple2 Local Repository Create New Branch 109 Exercise: Let’s create a New Branch named “develop”. /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  110. • Create New Branch (1-1) In Project Explore, right click

    on “simple2” project  Team  Switch To  New Branch… How to use EGit™? Branch/Tag “master” branch 110
  111. • Create New Branch (1-2) Enter “develop” in the Branch

    name field as New Branch and click “Finish” button. How to use EGit™? Branch/Tag “master” branch as Source 111
  112. • Check New Branch (1-3) Confirm New Branch in Project

    Explorer and Commit History. How to use EGit™? Branch/Tag Current Branch Local “develop” Branch 112
  113. Id: c2c8e3d • Merge Branches How to use EGit™? Branch/Tag

    “master” Branch “develop” Branch /repository/ simple2 Local Repository Merge Branches 113 Exercise: Let’s modify the “develop” branch and merge it into the “master” branch. Id: f87dfaa Modify /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  114. • Prepare for Merging Branches (1)  Edit App.java of

    “simple2” project on “develop” Branch further How to use EGit™? Branch/Tag Add 114
  115. • Prepare for Merging Branches (2) Commit on the “develop”

    Branch by right clicking on “simple2” project  Team  Commit… and select the updated file and set a commit message and click “Commit” button, but don’t click “Commit and Push” button. Confirm the “develop” Branch in Project Explore and Commit History. How to use EGit™? Branch/Tag “develop” Branch is different from “master” Branch Current Branch 115
  116. • Merge Branches (1)  In Project Explore, right click

    on “simple2” project  Team  Switch To  master Confirm that the current Branch is switched back to “master” in Project Explore. How to use EGit™? Branch/Tag 116
  117. • Merge Branches (2-1)  In Project Explore, right click

    on “simple2” project  Team  Merge… How to use EGit™? Branch/Tag 117
  118. • Merge Branches (2-2)  Select the “develop” Branch and

    click “Merge” button to merge the “develop” Branch to current “master” Branch. Confirm the result and click “OK” button. How to use EGit™? Branch/Tag 118
  119. • Merge Branches (2-3)  Confirm the “master” and “develop”

    Branches in Project Explore and Commit History. How to use EGit™? Branch/Tag “develop” Branch is equal to “master” Branch 119
  120. • Create Tag on the Current “master” Branch How to

    use EGit™? Branch/Tag “master” Branch “develop” Branch Id: c2c8e3d /repository/ simple2 Local Repository Tag: 1.0 120 Exercise: Let’s create a Tag on the Current “master” Branch. /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  121. • Create Tag on “master” Branch (1-1)  In Project

    Explore, right click on “simple2” project  Team  Advanced  Create Tag… How to use EGit™? Branch/Tag “master” branch 121
  122. • Create Tag on “master” Branch (1-2)  Fill in

    “Tag name” and “Tag message” fields and click “Create Tag” button. Check the created Tag in Commit History. How to use EGit™? Branch/Tag Created Tag 122
  123. • Push commits and tags on Local Branch to associated

    Remote Branch How to use EGit™? Pull/Push from/to Git™ Server Local Repository Branch: “master” /repository/ simple2 /projects.git/ simple2 Remote Repository Remote Name: “origin” Branch: ”master” Id: c2c8e3d Id: c2c8e3d Push Id: 1b692a3 123 Exercise: Let’s push commits and tags on Local Branch to the associated Remote Branch. /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  124. • Push commits and tags to existing Remote Branch (1)

    Confirm the status of Local and Remote Branches in Project Explore and Commit History. How to use EGit™? 2 Commits have not been pushed to Git™ Server yet Local “master” Branch Pull/Push from/to Git™ Server Remote “master” Branch Different Ids are pointed to. 124
  125. • Push commits and tags to existing Remote Branch (2-1)

    In Project Explore, right click on “simple2” project  Team  Push Branch ‘master’ … Check Source and Destination and Click “Preview >” button. How to use EGit™? Pull/Push from/to Git™ Server 125
  126. • Push commits and tags to existing Remote Branch (2-2)

    Confirm “Push” Preview and click “Push” button. Check the “Push” Results and click “Close” button. How to use EGit™? Pull/Push from/to Git™ Server 126
  127. • Push commits and tags to existing Remote Branch (2-3)

     Confirm the result in Project Explore and Commit History. How to use EGit™? Pull/Push from/to Git™ Server All Commits have been pushed to Git™ Server Local and Remote “master” Branches point to the same Id 127
  128. • Push new “develop” Branch to Remote Repository How to

    use EGit™? Pull/Push from/to Git™ Server Local Repository Branch: “develop” /repository/ simple2 /projects.git/ simple2 Remote Repository Remote Name: “origin” New Branch: ”develop” Id: c2c8e3d Push Id: c2c8e3d 128 Exercise: Let’s push the “develop” Local Branch to the Remote Repository. /ws1/ simple2 Eclipse Workspace Folder: “ws1”
  129. • Push new “develop” Branch to Remote Repository (1) Confirm

    the current status of “develop” branch in Project Explore and Commit History. How to use EGit™? Pull/Push from/to Git™ Server “develop” Branch exists only in the Local repository(There is no Remote “develop” Branch). Current Branch is “master”. 129
  130. • Push new “develop” Branch to Remote Repository (2) In

    Project Explore, right click on “simple2” project  Team  Switch To  develop How to use EGit™? Pull/Push from/to Git™ Server 130
  131. • Push new “develop” Branch to Remote Repository (3-1) In

    Project Explore, right click on project  Team  Push Branch ‘develop’ … Check Source and Destination and click “Preview>” button. How to use EGit™? Pull/Push from/to Git™ Server 131
  132. • Push new “develop” Branch to Remote Repository (3-2) Confirm

    the expected push result and click “Push” button. Confirm the result and click “Close” button. Confirm the Remote “develop” Branch was created. How to use EGit™? Pull/Push from/to Git™ Server Local and Remote “develop” Branches point to the same Id 132 New Branch
  133. • Pull and Import a new project from Remote Repository

    How to use EGit™? Pull/Push from/to Git™ Server Local Repository Branch: “master” /repository2/ simple /projects.git/ simple simple2 Remote Repository Remote Name: “origin” Branch: ”master” Eclipse Workplace Folder: “ws2” /ws2/ simple /repository2/ simple simple2 /ws2/ simple Pull /repository2/ simple simple2 /ws2/ simple simple2 Import There is no source file under /ws2, but only configuration for projects exists Old Version 133 Exercise: Let’s pull and import the “master” Branch from the Remote Repository. New Version Initial State Step. 1 Step. 2
  134. • Switch the Eclipse™ workplace to “ws2” (1) File 

    Switch Workspace  C:\Users\<UserId>\eclipse-workspace\ws2 How to use EGit™? Pull/Push from/to Git™ Server /ws2/ simple Eclipse Workplace Folder: “ws2” 134 \ws2 ws1
  135. • Pull the latest artifacts from remote repository (2) Right

    click on “simple” project and select  Team  Pull Check the Pull Result and click “Close” button. How to use EGit™? Pull/Push from/to Git™ Server /projects.git/ simple simple2 Pull /repository2/ simple simple2 /ws2/ simple Local Repository Branch: “master” Remote Repository Remote Name: “origin” Branch: ”master” Eclipse Workplace Folder: “ws2” Pull /ws2/ simple 135 Old simple project
  136. • Import “simple2” from the local repository (3-1) In Project

    Explorer, Select Import…  Select “Git” “Projects from Git” and click “Next>” button How to use EGit™? Pull/Push from/to Git™ Server /repository2/ simple simple2 /ws2/ simple simple2 Import Local Repository Branch: “master” Eclipse Workplace Directory: “ws2” 136
  137. • Import “simple2” from the local repository (3-2) Select “Existing

    local repository” and click “Next>” button  Select the local repository “repository2” and click “Next>” button How to use EGit™? Pull/Push from/to Git™ Server 137
  138. • Import “simple2” from the local repository (3-3) Select “Import

    existing Eclipse projects” and click “Next>” button  Select “simple2” project and click “Finish” button How to use EGit™? Pull/Push from/to Git™ Server 138
  139. • Pull a new “develop” Branch from Remote Branch How

    to use EGit™? Pull/Push from/to Git™ Server Local Repository New Branch: “develop” /repository2/ simple2 /projects.git/ simple2 Remote Repository Remote Name: “origin” Branch: ”develop” Id: c2c8e3d Id: c2c8e3d /ws2/ simple2 Eclipse Workplace Folder: “ws2” 139 Exercise: Let’s pull a new “develop” Branch from the Remote Repository.
  140. • Pull a new “develop” Branch from Remote Branch (1)

    Check the current status of Branch and confirm that the Local “develop” Branch does NOT exist. How to use EGit™? Pull/Push from/to Git™ Server Current Branch is “master” “develop” Branch exists only in the Remote repository. 140
  141. • Pull a new “develop” Branch from Remote Branch (2-1)

    In Project Explore, right click on project  Team  Switch To  New Branch… How to use EGit™? Pull/Push from/to Git™ Server 141
  142. • Pull a new “develop” Branch from Remote Branch (2-2)

    Click “Select…” button. Select “origin/develop” Branch and click “OK” button. Confirm Source is changed to “origin/develop” and Branch name becomes “develop” and click “Finish” button. How to use EGit™? Pull/Push from/to Git™ Server 142
  143. • Pull Latest Version from Remote Branch How to use

    EGit™? Pull/Push from/to Git™ Server Local Repository Branch: “develop” /repository/ simple2 /projects.git/ simple2 Remote Repository Remote Name: “origin” Branch: ”develop” Id: c6e6b98 Pull Id: c6e6b98 Id: c2c8e3d . . . Update Commit+Push Another Developer 143 Exercise: Let’s pull a new “develop” Branch from the Remote Repository. /ws1/ simple2 Eclipse Workplace Folder: “ws1” Local Repository Branch: “develop” /repository2/ simple2 Id: c6e6b98 /ws2/ simple2 Eclipse Workplace Folder: “ws2”
  144. • Pull Latest Version from Remote Branch (1) Modify the

    source file on the local “develop” branch. How to use EGit™? Pull/Push from/to Git™ Server 144 Save
  145. • Pull Latest Version from Remote Branch (2-1) Commit the

    modified project on the local “develop” branch and Push it to the remote repository. How to use EGit™? Pull/Push from/to Git™ Server 145
  146. • Pull Latest Version from Remote Branch (2-2) Commit the

    modified project on the local “develop” branch and Push it to the remote repository. How to use EGit™? Pull/Push from/to Git™ Server 146
  147. • Pull Latest Version from Remote Branch (3) Switch the

    Eclipse Workspace to “ws1”. How to use EGit™? Pull/Push from/to Git™ Server 147
  148. • Pull Latest Version from Remote Branch (4) Confirm the

    current status of Branch and the latest Id is “c2c8e3d”. How to use EGit™? Pull/Push from/to Git™ Server Current Branch is “develop” The Id for the local “develop” branch is “c2c8e3d”. 148
  149. • Pull Latest Version from Remote Branch (5-1)  In

    Project Explore, right click on project  Team  Pull How to use EGit™? Pull/Push from/to Git™ Server 149
  150. • Pull Latest Version from Remote Branch (5-2) Confirm the

    result and click “Close” button. Confirm the latest Id is changed to “c6e6b98”. How to use EGit™? Pull/Push from/to Git™ Server 150 The new “develop” Id is changed to “c6e6b98”.
  151. • Check the differences between Current Id (HEAD) and Specific

    Id/Tag How to use EGit™? Branch : Commit Points (HEAD) Commit Commit Commit Commit Commit Compare with Past Commit/Tag : Tags Compare 151
  152. • Check the differences between Current Id (HEAD) and Specific

    Id How to use EGit™? Local Repository Branch: “develop” /repository/ simple2 Id: c6e6b98 (HEAD) Id: c2c8e3d Check Differences Compare with Past Commit/Tag 152 Exercise: Let’s check the differences in source files between HEAD and the previous commit. /ws1/ simple2 Eclipse Workplace Folder: “ws1”
  153. • Check the differences between Current Id (HEAD) and Specific

    Id (1-1)  In Project Explore, right click on “simple2” project  Compare With  Commit… How to use EGit™? Compare with Past Commit/Tag 153
  154. • Check the differences between Current Id (HEAD) and Specific

    Id (1-2)  Select the target compared Id and click “OK” button.  Confirm Open Perspective Dialog menu and click “Yes” button. How to use EGit™? Compare with Past Commit/Tag 154
  155. • Check the differences between Current Id (HEAD) and Specific

    Id (2-1)  In Synchronize pane, confirm the different files are listed.  Right click on a different file and select “Open In Compare Editor” menu. How to use EGit™? Compare with Past Commit/Tag 155
  156. • Check the differences between Current Id (HEAD) and Specific

    Id (2-2)  Confirm the different lines of the selected file. How to use EGit™? Compare with Past Commit/Tag 156
  157. • Check the differences between Current Id (HEAD) and Specific

    Tag How to use EGit™? Local Repository Branch: “develop” /repository/ simple2 Id: c6e6b98 (HEAD) Tag: 1.0 Check Differences Compare with Past Commit/Tag 157 /ws1/ simple2 Eclipse Workplace Folder: “ws1” Exercise: Let’s check the differences in source files between HEAD and the commit tagged “1.0”.
  158. • Check the differences between Current Id (HEAD) and Specific

    Tag (1-1)  In Project Explore, right click on project  Compare With  Branch, Tag or Reference… How to use EGit™? Compare with Past Commit/Tag 158
  159. • Check the differences between Current Id (HEAD) and Specific

    Tag (1-2)  Select the target compared Tag and click “Compare” button.  Confirm Open Perspective Dialog menu and click “Yes” button. How to use EGit™? Compare with Past Commit/Tag 159
  160. • Check the differences between Current Id (HEAD) and Specific

    Tag (1-3)  In Synchronize pane, confirm the different files are listed.  Right click on a different file and select “Open In Compare Editor” menu. How to use EGit™? Compare with Past Commit/Tag 160
  161. • Check the differences between Current Id (HEAD) and Specific

    Tag (1-4)  Confirm the different lines of the selected file. How to use EGit™? Compare with Past Commit/Tag 161
  162. • Checkout a Past Commit/Tag How to use EGit™? Branch

    : Commit Points (HEAD) Commit Commit Commit Commit Commit : Tags Checkout Checkout Past Commit/Tag Old Project Files 162
  163. • Checkout a Past Tagged Commit How to use EGit™?

    Local Repository Branch: “develop” /repository2/ simple2 Id: ce9ec66 (HEAD) Id: c2c8e3d Tag: 1.0 Checkout Past Commit/Tag Checkout 163 /ws1/ simple2 Eclipse Workplace Folder: “ws1” Exercise: Let’s check out source files of the project with the commit tagged “1.0”.
  164. • Checkout a Past Tagged Commit (1)  In History

    pane, right click on the target Tag  Check Out Confirm the target project was checked out. How to use EGit™? Checkout Past Commit/Tag Check Out 164 You can switch back to “HEAD” by switching to the “develop” branch
  165. Exercise 165

  166. Exercise1 • Create Git™ “bare” remote repository named “exercise.git” under

    a directory of “/var/lib/git” on Git™ Server. CentOS 8 Git™ Product SSH “bare” repository: “/var/lib/git/exercise.git” Git™ User: “git” firewalld 166
  167. Exercise2 • Set up Git™ repositories for a Eclipse project

    of “simple” with EGit™ Not Existed /exercise.git Local Repository Remote Repository Only the bare repository is created. /exercise/ exercise1 /ws1/exercise1 /exercise.git/ exercise1 “master” branch Git™ Server IP: 192.168.22.10 Git Folder: /var/lib/git Git User: git Eclipse Workspace Folder: “ws1” “master” branch in Local Repository Git Folder: C:\Users\<UserId>\git /ws1/exercise1 Eclipse Workspace 167
  168. • Create New Branch (named “develop”) Exercise3 (1) “master” Branch

    “develop” Branch Id: xxxxxxx /exercise/ exercise1 Local Repository Create New Branch 168 /ws1/ exercise1 Eclipse Workspace Folder: “ws1” /exercise.git/ exercise1 Remote Repository
  169. • Update & Commit to “develop” Branch Exercise3 (2) “master”

    Branch “develop” Branch /exercise/ exercise1 Local Repository Update & Commit Id: yyyyy 169 /ws1/ exercise1 Eclipse Workspace Folder: “ws1” /exercise.git/ exercise1 Remote Repository
  170. • Merge “develop” Branch to “master” Branch Exercise3 (3) “master”

    Branch “develop” Branch /exercise/ exercise1 Local Repository Merge Id: yyyyy 170 /ws1/ exercise1 Eclipse Workspace Folder: “ws1” /exercise.git/ exercise1 Remote Repository
  171. • Attach a Tag named “Release_1.2” to “master” Branch Exercise3

    (4) “master” Branch “develop” Branch /exercise/ exercise1 Local Repository Tag Release_1.2 171 /ws1/ exercise1 Eclipse Workspace Folder: “ws1” /exercise.git/ exercise1 Remote Repository