SlideShare a Scribd company logo
Merge, Rebase and how to resolve
Conflicts
In this exercise you will learn how to combine the work done in different branches and how
to resolve the conflicts which can occur during that process.
Preparation
Follow exercise 2, “Develop a feature/bug fix” to create a commit on a feature branch based
on the remote tracking branch origin/master.
Create a Conflicting commit
You may skip this step if you have already created conflicting changes in the previous
exercises. This is the case if you touched exactly the same line of the same file in different
feature branches. If this is not the case please do the following:
● Create a new local branch based on the remote tracking branch “origin/master”
● Create the new branch from the History View :
○ Select the project, then click Show In > History
○ Click “Create Branch...” on the commit where origin/master points to
● Do a different change in the same class on the same line as in the other branch (e.g.
you may add a class MultiplyOperation and add a corresponding line to method
setupDefaultOperations in class Calculator) and commit this change.
Merge the feature branches
Now you would like to have both new features in the master branch. One possibility to
achieve that is to merge the branches into the master branch, one after the other. Later in
this exercise you will learn another way, rebasing.
Trigger the first merge from the history view
● Check out the branch master where you want to have the merged state, i.e. where
the merge commit will be created, either by double clicking in the Repositories View,
or by selecting Checkout in the History View, or by using Team > Switch to > master,
or using the Checkout button in the Git tool bar.
● In the History View, select Merge in the context menu of the addDivide branch.
This will merge the content of the addDivde branch into the master branch. Since
there was no work done on the master branch and addDivide points to a successor
commit of the commit in master there is not much to do.
● Git simply forwards the master branch to the same commit as the addDivide
branch.
● Inspect the result in the history view.
Merge the second branch
● In the History View, select Merge in the context menu of the branch which contains
the conflicting commit. This will merge the content of this branch into the master
branch. This time the merge operation ends with conflicts.
Resolving merge conflicts
If a merge generates conflicts the repository is in a special state. The conflicts have to be
resolved until normal work can go on.
You can find the conflicting files by the conflict decorator in the package explorer::
If there are many conflicts it’s easier to find them in the Git Staging View:
● If you open the conflicting file in an editor you will find the conflict markers there. You
can directly edit the file here.
● You may use the Merge tool to resolve the conflicts: Select Merge Tool on the
conflicting file in the Staging View or “Team > Merge Tool” in the package explorer.
● By default the merge tool will show the two versions being merged, you can also
choose to let git pre-merge the file content by setting “Preferences > Team > Git
> Merge Tool Content” to “Workspace (pre-merged by Git)”. In this case conflict
markers are shown in the left pane in the file content pre-merged by git
● Click “Copy Current Change from Right to Left”
to take over the current change from right to left
● or edit the left side until you are happy with the change and save the file
● Now stage these modifications in the staging view or click “Team > Add to Index” on
the file. This marks the conflict as resolved and adds the conflict resolution to the git
index to add the conflict resolution to the merge commit in the next step.
● Click “Commit” in the Staging View. Note that git generates a merge commit
message. Leave it as it is, but do not forget the Change-Id-line in the Staging View if
you want to push the change to Gerrit later.
Undo merging with Reset
After you have done a merge as described above assume that you do not want the merge
commit in your branch anymore. You can easily undo the merge with the Reset operation.
(The same can also be done if the merge is not finished but your repository is in state
“Conflicting” or “Merged”).
● Select Reset > Hard on the commit where the branch pointed to before you did the
first merge.
Rebase
Now do a rebase of the conflicting commit instead of a merge.
● In the History View, check out one of the feature branches
● In the History View, select Rebase on on the second feature branch (the first one is
checked out):
● The rebase stops because of the conflict and shows the following dialog:
● Click Ok to start the merge tool.
● Again use the Merge tool to resolve the conflicts. Again as shown above for merge
you can adjust setting “Merge tool content” to let git pre-merge the file content in the
preferences.
Edit the left side until you are happy with the change and save
● Now open the Git Staging View
● Move the conflicting file to the “Staged Changes” area to tell git that the conflict is
resolved. If there are no conflicting files anymore, the “Continue” button gets enable.
Click the “Continue” button. Note: rebase is continued by a different operation
(“Continue”) than merge (“Commit”) since rebase is a multi-step operation which may
raise conflicts multiple times if you you are not only rebasing a single but multiple
commits in one go.
● Now the version graph should look like this: Note that there is a reference
ORIG_HEAD pointing to the commit which was checked out before the rebase
operation. You may revert the rebase operation with reset as described above.
● Now you may want to move the master branch to the rebased commit
○ Check out the master branch
○ Select “Rebase On” on the rebased commit
Copyright © 2014 by C. Halstrick, E. Kempin, S. Lay, S. Zivkov

More Related Content

Viewers also liked

Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
msohn
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest stateGit Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
msohn
 
Git missiontomars 2015-03-10
Git missiontomars 2015-03-10Git missiontomars 2015-03-10
Git missiontomars 2015-03-10
msohn
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
msohn
 
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blameGit Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
msohn
 
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebaseGit Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
msohn
 
The Git Tutorial - EclipseCon 2012
The Git Tutorial - EclipseCon 2012The Git Tutorial - EclipseCon 2012
The Git Tutorial - EclipseCon 2012
msohn
 
Git journey from mars to neon EclipseCon North America - 2016-03-08
Git journey from mars to neon   EclipseCon North America - 2016-03-08Git journey from mars to neon   EclipseCon North America - 2016-03-08
Git journey from mars to neon EclipseCon North America - 2016-03-08
msohn
 
Effective Git - EclipseCon 2011 tutorial
Effective Git - EclipseCon 2011 tutorialEffective Git - EclipseCon 2011 tutorial
Effective Git - EclipseCon 2011 tutorial
msohn
 
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014msohn
 
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - LudwigsburgNews from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
msohn
 
Git and Eclipse - Eclipse Helios DemoCamp Jena 2010
Git and Eclipse - Eclipse Helios DemoCamp Jena 2010Git and Eclipse - Eclipse Helios DemoCamp Jena 2010
Git and Eclipse - Eclipse Helios DemoCamp Jena 2010
msohn
 
EclipseCon 2010 talk: Towards contributors heaven
EclipseCon 2010 talk: Towards contributors heavenEclipseCon 2010 talk: Towards contributors heaven
EclipseCon 2010 talk: Towards contributors heaven
msohn
 
Versioning large binary files with JGit, EGit and Gerrit
Versioning large binary files with JGit, EGit and GerritVersioning large binary files with JGit, EGit and Gerrit
Versioning large binary files with JGit, EGit and Gerrit
msohn
 
Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12
Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12
Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12
msohn
 
Passé composé auxiliaire avoir
Passé composé auxiliaire avoirPassé composé auxiliaire avoir
Passé composé auxiliaire avoirantjosegarcia
 

Viewers also liked (19)

Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
Git Tutorial EclipseCon France 2014 - Git Exercise 01 - installation and conf...
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest stateGit Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 2 - fetch the latest state
 
Git missiontomars 2015-03-10
Git missiontomars 2015-03-10Git missiontomars 2015-03-10
Git missiontomars 2015-03-10
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 9 - starting demo gerrit
 
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blameGit Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
Git Tutorial EclipseCon France 2014 - Git Exercise 07 - git blame
 
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebaseGit Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
Git Tutorial EclipseCon France 2014 - Git Exercise 06 - interactive rebase
 
The Git Tutorial - EclipseCon 2012
The Git Tutorial - EclipseCon 2012The Git Tutorial - EclipseCon 2012
The Git Tutorial - EclipseCon 2012
 
Git journey from mars to neon EclipseCon North America - 2016-03-08
Git journey from mars to neon   EclipseCon North America - 2016-03-08Git journey from mars to neon   EclipseCon North America - 2016-03-08
Git journey from mars to neon EclipseCon North America - 2016-03-08
 
Effective Git - EclipseCon 2011 tutorial
Effective Git - EclipseCon 2011 tutorialEffective Git - EclipseCon 2011 tutorial
Effective Git - EclipseCon 2011 tutorial
 
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
Code Matters - Eclipse Hackers Git Guide - EclipseCon France 2014
 
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - LudwigsburgNews from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
News from EGit - Talk EclipseCon Europe 2014 - Ludwigsburg
 
Git and Eclipse - Eclipse Helios DemoCamp Jena 2010
Git and Eclipse - Eclipse Helios DemoCamp Jena 2010Git and Eclipse - Eclipse Helios DemoCamp Jena 2010
Git and Eclipse - Eclipse Helios DemoCamp Jena 2010
 
EclipseCon 2010 talk: Towards contributors heaven
EclipseCon 2010 talk: Towards contributors heavenEclipseCon 2010 talk: Towards contributors heaven
EclipseCon 2010 talk: Towards contributors heaven
 
Versioning large binary files with JGit, EGit and Gerrit
Versioning large binary files with JGit, EGit and GerritVersioning large binary files with JGit, EGit and Gerrit
Versioning large binary files with JGit, EGit and Gerrit
 
Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12
Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12
Cool new stuff in JGit and EGit - Eclipse Democamp Munich 2013-06-12
 
A, as ou à
A, as ou àA, as ou à
A, as ou à
 
Futur pierre
Futur pierreFutur pierre
Futur pierre
 
Ratatouille 2ºeso
Ratatouille      2ºesoRatatouille      2ºeso
Ratatouille 2ºeso
 
Passé composé auxiliaire avoir
Passé composé auxiliaire avoirPassé composé auxiliaire avoir
Passé composé auxiliaire avoir
 

Similar to Git Tutorial EclipseCon France 2014 - Git Exercise 04 - merging rebasing and resolving conflicts

Git Branching and Merging.pptx
Git Branching and Merging.pptxGit Branching and Merging.pptx
Git Branching and Merging.pptx
tapanvyas11
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
LearningTech
 
wdt_09.pptx
wdt_09.pptxwdt_09.pptx
wdt_09.pptx
HamdiAlaqal
 
E caregitpresentation
E caregitpresentationE caregitpresentation
E caregitpresentation
Rakesh Kumar Shardiwal
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
Sebin Benjamin
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
Hasnaeen Rahman
 
Git Best Practices.pptx
Git Best Practices.pptxGit Best Practices.pptx
Git Best Practices.pptx
ArchanaVaidya15
 
Git Tutorials Git vs GitHub.pptx
Git Tutorials Git vs GitHub.pptxGit Tutorials Git vs GitHub.pptx
Git Tutorials Git vs GitHub.pptx
DevOps University
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced gitGerrit Wanderer
 
Github
GithubGithub
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
Md. Ahsan Habib Nayan
 
GDSC Git event 2023.pptx
GDSC Git event 2023.pptxGDSC Git event 2023.pptx
GDSC Git event 2023.pptx
fsxflyer789Productio
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
murad khan
 
Patch File.pdf
Patch File.pdfPatch File.pdf
Patch File.pdf
vilaylala
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
Yeasin Abedin
 
Technical Seminar Series: GIT Pull Requests Best Practices
Technical Seminar Series:  GIT Pull Requests Best PracticesTechnical Seminar Series:  GIT Pull Requests Best Practices
Technical Seminar Series: GIT Pull Requests Best Practices
Singsys Pte Ltd
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
mobaires
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for developmentGerrit Wanderer
 
GIT Workflows
GIT Workflows GIT Workflows
GIT Workflows
BraveBits
 

Similar to Git Tutorial EclipseCon France 2014 - Git Exercise 04 - merging rebasing and resolving conflicts (20)

Git Branching and Merging.pptx
Git Branching and Merging.pptxGit Branching and Merging.pptx
Git Branching and Merging.pptx
 
Git tutorial git branches 20131206-Bryan
Git tutorial   git branches 20131206-BryanGit tutorial   git branches 20131206-Bryan
Git tutorial git branches 20131206-Bryan
 
wdt_09.pptx
wdt_09.pptxwdt_09.pptx
wdt_09.pptx
 
E caregitpresentation
E caregitpresentationE caregitpresentation
E caregitpresentation
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
Git Best Practices.pptx
Git Best Practices.pptxGit Best Practices.pptx
Git Best Practices.pptx
 
Git Tutorials Git vs GitHub.pptx
Git Tutorials Git vs GitHub.pptxGit Tutorials Git vs GitHub.pptx
Git Tutorials Git vs GitHub.pptx
 
GIT Rebasing and Merging
GIT Rebasing and MergingGIT Rebasing and Merging
GIT Rebasing and Merging
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Github
GithubGithub
Github
 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
 
GDSC Git event 2023.pptx
GDSC Git event 2023.pptxGDSC Git event 2023.pptx
GDSC Git event 2023.pptx
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Patch File.pdf
Patch File.pdfPatch File.pdf
Patch File.pdf
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
Technical Seminar Series: GIT Pull Requests Best Practices
Technical Seminar Series:  GIT Pull Requests Best PracticesTechnical Seminar Series:  GIT Pull Requests Best Practices
Technical Seminar Series: GIT Pull Requests Best Practices
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
 
GIT Workflows
GIT Workflows GIT Workflows
GIT Workflows
 

More from msohn

Project Gardener - EclipseCon Europe - 2018-10-23
Project Gardener - EclipseCon Europe - 2018-10-23Project Gardener - EclipseCon Europe - 2018-10-23
Project Gardener - EclipseCon Europe - 2018-10-23
msohn
 
News from Git in Eclipse - EclipseCon EU - 2016-10-26
News from Git in Eclipse - EclipseCon EU - 2016-10-26News from Git in Eclipse - EclipseCon EU - 2016-10-26
News from Git in Eclipse - EclipseCon EU - 2016-10-26
msohn
 
News from Git in Eclipse - EclipseCon 2015 Europe
News from Git in Eclipse - EclipseCon 2015 EuropeNews from Git in Eclipse - EclipseCon 2015 Europe
News from Git in Eclipse - EclipseCon 2015 Europe
msohn
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a changeGit Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
msohn
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
msohn
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
msohn
 
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history viewGit Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
msohn
 
Interactive Rebase with EGit
Interactive Rebase with EGitInteractive Rebase with EGit
Interactive Rebase with EGit
msohn
 
EGit 3.0 and beyond
EGit 3.0 and beyondEGit 3.0 and beyond
EGit 3.0 and beyond
msohn
 
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
msohn
 
News from Git in Java Land
News from Git in Java LandNews from Git in Java Land
News from Git in Java Land
msohn
 
Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02
Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02
Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02
msohn
 

More from msohn (12)

Project Gardener - EclipseCon Europe - 2018-10-23
Project Gardener - EclipseCon Europe - 2018-10-23Project Gardener - EclipseCon Europe - 2018-10-23
Project Gardener - EclipseCon Europe - 2018-10-23
 
News from Git in Eclipse - EclipseCon EU - 2016-10-26
News from Git in Eclipse - EclipseCon EU - 2016-10-26News from Git in Eclipse - EclipseCon EU - 2016-10-26
News from Git in Eclipse - EclipseCon EU - 2016-10-26
 
News from Git in Eclipse - EclipseCon 2015 Europe
News from Git in Eclipse - EclipseCon 2015 EuropeNews from Git in Eclipse - EclipseCon 2015 Europe
News from Git in Eclipse - EclipseCon 2015 Europe
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a changeGit Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 6 - submit a change
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerritGit Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 1 - configure for gerrit
 
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
Git Tutorial EclipseCon France 2014 - Gerrit Exercise 8 - view gerrit review ...
 
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history viewGit Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
Git Tutorial EclipseCon France 2014 - Git Exercise 05 - history view
 
Interactive Rebase with EGit
Interactive Rebase with EGitInteractive Rebase with EGit
Interactive Rebase with EGit
 
EGit 3.0 and beyond
EGit 3.0 and beyondEGit 3.0 and beyond
EGit 3.0 and beyond
 
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
 
News from Git in Java Land
News from Git in Java LandNews from Git in Java Land
News from Git in Java Land
 
Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02
Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02
Eclipse Hackers Guide to the Git Universe - Eclipse democamp Vienna 2011-12-02
 

Recently uploaded

Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
Matt Welsh
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
IES VE
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 

Recently uploaded (20)

Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Large Language Models and the End of Programming
Large Language Models and the End of ProgrammingLarge Language Models and the End of Programming
Large Language Models and the End of Programming
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 

Git Tutorial EclipseCon France 2014 - Git Exercise 04 - merging rebasing and resolving conflicts

  • 1. Merge, Rebase and how to resolve Conflicts In this exercise you will learn how to combine the work done in different branches and how to resolve the conflicts which can occur during that process. Preparation Follow exercise 2, “Develop a feature/bug fix” to create a commit on a feature branch based on the remote tracking branch origin/master. Create a Conflicting commit You may skip this step if you have already created conflicting changes in the previous exercises. This is the case if you touched exactly the same line of the same file in different feature branches. If this is not the case please do the following: ● Create a new local branch based on the remote tracking branch “origin/master” ● Create the new branch from the History View : ○ Select the project, then click Show In > History ○ Click “Create Branch...” on the commit where origin/master points to ● Do a different change in the same class on the same line as in the other branch (e.g. you may add a class MultiplyOperation and add a corresponding line to method setupDefaultOperations in class Calculator) and commit this change.
  • 2. Merge the feature branches Now you would like to have both new features in the master branch. One possibility to achieve that is to merge the branches into the master branch, one after the other. Later in this exercise you will learn another way, rebasing. Trigger the first merge from the history view ● Check out the branch master where you want to have the merged state, i.e. where the merge commit will be created, either by double clicking in the Repositories View, or by selecting Checkout in the History View, or by using Team > Switch to > master, or using the Checkout button in the Git tool bar. ● In the History View, select Merge in the context menu of the addDivide branch. This will merge the content of the addDivde branch into the master branch. Since there was no work done on the master branch and addDivide points to a successor commit of the commit in master there is not much to do. ● Git simply forwards the master branch to the same commit as the addDivide branch. ● Inspect the result in the history view.
  • 3. Merge the second branch ● In the History View, select Merge in the context menu of the branch which contains the conflicting commit. This will merge the content of this branch into the master branch. This time the merge operation ends with conflicts. Resolving merge conflicts If a merge generates conflicts the repository is in a special state. The conflicts have to be resolved until normal work can go on. You can find the conflicting files by the conflict decorator in the package explorer:: If there are many conflicts it’s easier to find them in the Git Staging View: ● If you open the conflicting file in an editor you will find the conflict markers there. You can directly edit the file here.
  • 4. ● You may use the Merge tool to resolve the conflicts: Select Merge Tool on the conflicting file in the Staging View or “Team > Merge Tool” in the package explorer. ● By default the merge tool will show the two versions being merged, you can also choose to let git pre-merge the file content by setting “Preferences > Team > Git > Merge Tool Content” to “Workspace (pre-merged by Git)”. In this case conflict markers are shown in the left pane in the file content pre-merged by git ● Click “Copy Current Change from Right to Left” to take over the current change from right to left
  • 5. ● or edit the left side until you are happy with the change and save the file ● Now stage these modifications in the staging view or click “Team > Add to Index” on the file. This marks the conflict as resolved and adds the conflict resolution to the git index to add the conflict resolution to the merge commit in the next step. ● Click “Commit” in the Staging View. Note that git generates a merge commit message. Leave it as it is, but do not forget the Change-Id-line in the Staging View if you want to push the change to Gerrit later. Undo merging with Reset After you have done a merge as described above assume that you do not want the merge commit in your branch anymore. You can easily undo the merge with the Reset operation. (The same can also be done if the merge is not finished but your repository is in state “Conflicting” or “Merged”). ● Select Reset > Hard on the commit where the branch pointed to before you did the first merge.
  • 6. Rebase Now do a rebase of the conflicting commit instead of a merge. ● In the History View, check out one of the feature branches ● In the History View, select Rebase on on the second feature branch (the first one is checked out): ● The rebase stops because of the conflict and shows the following dialog:
  • 7. ● Click Ok to start the merge tool. ● Again use the Merge tool to resolve the conflicts. Again as shown above for merge you can adjust setting “Merge tool content” to let git pre-merge the file content in the preferences. Edit the left side until you are happy with the change and save
  • 8. ● Now open the Git Staging View ● Move the conflicting file to the “Staged Changes” area to tell git that the conflict is resolved. If there are no conflicting files anymore, the “Continue” button gets enable. Click the “Continue” button. Note: rebase is continued by a different operation (“Continue”) than merge (“Commit”) since rebase is a multi-step operation which may raise conflicts multiple times if you you are not only rebasing a single but multiple commits in one go.
  • 9. ● Now the version graph should look like this: Note that there is a reference ORIG_HEAD pointing to the commit which was checked out before the rebase operation. You may revert the rebase operation with reset as described above. ● Now you may want to move the master branch to the rebased commit ○ Check out the master branch ○ Select “Rebase On” on the rebased commit Copyright © 2014 by C. Halstrick, E. Kempin, S. Lay, S. Zivkov