Branches

  1. Fix some issues
  2. Implements another feature
  3. Merge with Conflict
  4. Rebase with Conflict

Fix some issues

  • Close opened projects and open the HelloWorld-6 project
  • Fix the Javadoc and Commit.
  • Fix label and Commit.
    System.out.println("Hello EclipseCon !");
    Fix issues

Implements another feature

  • Create the Arguments branch.
  • Update Main to handle 0 argument, and Commit.
    public static void main(String[] args) {
    	if (args.length == 0) {
    		System.out.println("Hello EclipseCon !");
    	}
    }
  • Update Main to handle more arguments and Commit.
    public static void main(String[] args) {
    	if (args.length == 0) {
    		System.out.println("Hello EclipseCon !");
    	} else {
    		String greeting = String.format("Hello %s !", args[0]);
    		System.out.println(greeting);
    	}
    }

Merge with Conflict

  • Checkout to master branch
  • Merge master with GreetingService
    Merge
  • Merge Conflict
    To solve the conflict you need to fix Main.
    public static void main(String[] args) {
    	GreetingService greetingService = new GreetingService();
    	System.out.println(greetingService.greeting());
    }
    Add the Main to the staging area (mark the conflict resolved).
    Report modification to GreetingService.
    public String greeting() {
    	return "Hello EclipseCon !";
    }
    Stage the GreetingService.
    Then Commit.

    Note
    You can Reset... to cancel the merge

Rebase with Conflict

  • Checkout to Arguments branch
  • Rebase on top of master.
    Rebase
  • To solve the conflict, set Start Merge Tool to resolve conflicts.
    Choose the Use HEAD (...) of conflicting files.
    Merge Tool

    Note
    EGit 3.0 improved displaying conflicts a bit nicer and also features 3 way comparison in more places.
    EGit 3.0 is coming with Kepler

  • Merge the code:
    	public static void main(String[] args) {
    		GreetingService greetingService = new GreetingService();
    		if (args.length == 0) {
    			System.out.println(greetingService.greeting());
    		}
    	}
  • Stage the Main.
    Now we should continue the rebase. Choose Team > Rebase > Continue Rebase on the contextual menu of the project into the Package Explorer view.
  • There is another conflicts with the second step of the rebase.
    Fix it with:
    	public static void main(String[] args) {
    		GreetingService greetingService = new GreetingService();
    		if (args.length == 0) {
    			System.out.println(greetingService.greeting());
    		} else {
    			String greeting = String.format("Hello %s !", args[0]);
    			System.out.println(greeting);
    		}
    	}
  • Stage the Main and Continue Rebase.
  • The rebase finish successfully.
  • Note
    Don't be afraid by rebase, most of time conflicts are rare and easy to resolve. In the worst case you can Abort Rebase to retrieve the initial state.