You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@taverna.apache.org by Stian Soiland-Reyes <st...@apache.org> on 2016/06/06 12:56:55 UTC

Resolving merge conflicts

Here's a walk-through I did with Thilina on solving a merge conflict.

The basis is that the pull request at
https://github.com/apache/incubator-taverna-common-activities/pull/4

says:

> This branch has conflicts that must be resolved


That is typically because both you and someone else (e.g. in this case
me) have changed the same file.


Here's what you can do

git status ## ensure everything is checked in
git checkout cwl-browse ## branch of the pull request

# Fetch the latest branch we want to merge into
git remote add apache
git://git.apache.org/incubator-taverna-common-activities.git
git fetch apache
git merge apache/cwl-browse


Auto-merging taverna-external-tool-activity/src/main/java/org/apache/taverna/activities/externaltool/desc/RuntimeEnvironment.java
Removing taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/InvocationException.java
Removing taverna-external-tool-activity/src/main/java/de/uni_luebeck/inb/knowarc/usecases/invocation/AskUserForPw.java
Auto-merging pom.xml
CONFLICT (content): Merge conflict in pom.xml
Automatic merge failed; fix conflicts and then commit the result.

You see git does a good job when our changes are not in conflict, but
both have edited pom.xml around the same lines, so that have to be
fixed manually.

git status

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   pom.xml

Open pom.xml in an editor, which should highlight the merge conflict -
in this case:


<<<<<<< HEAD
    <module>taverna-cwl-activity-ui</module>
  </modules>
=======
        </modules>
        <build>
                <plugins>
                        <plugin>
                                <groupId>org.apache.rat</groupId>
                                <artifactId>apache-rat-plugin</artifactId>
                                <configuration>
                                        <excludes combine.children="append">

<exclude>**/src/main/resources/META-INF/soap-encoding.xsd</exclude>
<!-- W3C Software License (See NOTICE) -->

<exclude>**/src/test/resources/test-spreadsheet*</exclude> <!--  Our
own test spreadsheets -->

<exclude>**/src/main/resources/json2.js</exclude><!-- public domain
-->
                                        </excludes>
                                </configuration>
                        </plugin>
                </plugins>
        </build>
>>>>>>> apache/cwl-browse

So Thilina has added a new <module>, but someone has added a new
<plugin> configuration in the apache repository. In this particular
case we want both changes to survive, so we can simply remove the <<<<
==== and >>> markers, and also remove the then duplicate </modules>

Then we scan the rest of the files for any more <<< markers.. which
there are none.

Run mvn clean

to be sure the pom.xml parses still.


so we tell git we have solved the conflict in this file:

git add pom.xml

git status

should now have all in green, so we can commit the merge

git commit



(the default message for merges are generally OK unless we had to do
some other change)

now we can push to github again


git push

and the pull request should update and be happy.. as now your pull
request can be merged without conflicts.



Note that it's also possible to use "git rebase" instead of git merge
- in some ways this is cleaner as it means your branch will be
rewritten to be added on top of the latest commits - but this can
sometimes give you many more conflicts to solve, e.g. because you have
done many commits, or it's been a long time since last time you
rebase. Also if you use git rebase to rewrite your history, you would
need to use "git push --force" to rewrite history also on your github
branch.



More info from the Git book, with fancy graphics:

https://git-scm.com/book/en/v2/Git-Branching-Basic-Branching-and-Merging
https://git-scm.com/book/en/v2/Git-Branching-Rebasing



-- 
Stian Soiland-Reyes
Apache Taverna (incubating), Apache Commons
http://orcid.org/0000-0001-9842-9718

Re: Resolving merge conflicts

Posted by Thilina Manamgoda <ma...@gmail.com>.
hi,
can you try again . i have followed the instructions .

regards,
Thilina