threads / discuss / 24636

git merge - "both added" conflict resolution

Subject: git merge - "both added" conflict resolution

## tl;dr

6 messages between Aug 4, 2010 and Aug 6, 2010.

replies: 5people: 2as markdown or json

Eugene Sajine· Aug 4, 2010, 20:18 UTC · lore
hi,

I'm trying to merge two projects into one. Both are having different and simple set of files inside, but both have build.xml file. Let's say i have source repo with master branch and dest repo.

When i'm trying to merge source into dest it all goes well with an exception of the build.xml file - it has conflict. The conflict is one liner and is easy to resolve, eventually i want it to be as it was before the merge. First of all, after the merge git status gives me message "both added; build.xml" not both modified, which is understandable, but i have no clue yet how to work with it;)

Secondly, when i resolve the conflict the build.xml returns to its last committed state of dest repo, so git cannot determine any changes. Therefore, i cannot execute git add for this file and i cannot commit my merge results, because git sees it as a partial commit.

Any ideas?

Thanks, Eugene

Jonathan Nieder· Aug 4, 2010, 20:59 UTC · re: Eugene Sajine · lore

Re: git merge - "both added" conflict resolution

Hi Eugene,
Eugene Sajine wrote:
[in an add/add conflict]
Show 5 quoted lines
>           when i resolve the conflict the build.xml returns to its
> last committed state of dest repo, so git cannot determine any
> changes.
> Therefore, i cannot execute git add for this file and i cannot commit
> my merge results

Could you explain further (preferrably with a simple example transcript)? I would think that after an add/add conflict, a simple "git add" would mark the file resolved and allow committing.

Eugene Sajine· Aug 4, 2010, 23:29 UTC · re: Jonathan Nieder · lore

Re: git merge - "both added" conflict resolution

On Wed, Aug 4, 2010 at 4:59 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 16 quoted lines
> Hi Eugene,
>
> Eugene Sajine wrote:
>
> [in an add/add conflict]
>>           when i resolve the conflict the build.xml returns to its
>> last committed state of dest repo, so git cannot determine any
>> changes.
>> Therefore, i cannot execute git add for this file and i cannot commit
>> my merge results
>
> Could you explain further (preferrably with a simple example
> transcript)?  I would think that after an add/add conflict,
> a simple "git add" would mark the file resolved and allow
> committing.
>

Let's say in a source repository i have a master branch with few coomits and only two files file1.java and build.xml build.xml is as simple as few lines one of which is ... <property name=projectName value=projectOne/> ... In the second *unrelated* repository which is the destination for merge I have a master branch with two files: file2.java and build.xml this build.xml is absolutely identical with an exception of the projectName property ... <property name=projectName value=projectTwo/> ...

I'm doing $ cd projecttwo (I'm in master branch) $ git add remote temp ../projectone $ git fetch temp $ git merge temp/master

here i'm getting a conflict in build.xml. file1.java is succesfully staged for commit

For build.xml git status gives me ... both added: build.xml ...

Now i have to resolve the conflict on build.xml and as I'm merging two projects into one it is obvious that the resolution of the conflict is to leave the original version of build.xml

So, I'm removing all conflict markers and removing the incoming line with the property value=projectOne leaving it as projectTwo. This effectively means that there is no changes in build.xml for git. And I'm stuck because i cannot add file, that is not changed and cannot commit merge results as it is a partial commit.

Is that better;)?

Interesting enough this worked OK on git version 1.6.4.msysgit.0 But giving me headache in git 1.7.0.5 on Linux

Below is command sequence which is supposed to reflect everything above

mkdir test3 mkdir test4 cd test3/ git init echo file content> file1.java git add . git commit -am "initial commit" echo "<property name=projectname value=test3/>" > build.xml git add . git commit -am "add build.xml" echo "more content" >> file1.java git commit -am "some change" cd ../test4 git init echo file content> file2.java git add . git commit -am "initial commit" echo "<property name=projectname value=test4/>" > build.xml git add . git commit -am "add build.xml" echo "more content" >> file2.java git commit -am "another change" git remote add temp ../test3 git fetch temp git merge temp/master git status vi build.xml git status git add build.xml git st git commit -am "merging"

Thanks, Eugene

Jonathan Nieder· Aug 4, 2010, 23:36 UTC · re: Eugene Sajine · lore

Re: git merge - "both added" conflict resolution

Eugene Sajine wrote:
> So, I'm removing all conflict markers and removing the incoming line
> with the property value=projectOne leaving it as projectTwo.
> This effectively means that there is no changes in build.xml for git.
> And I'm stuck because i cannot add file, that is not changed

Sorry I wasn’t clear before. Could you give output from attempting to add the file? It is supposed to work.

Eugene Sajine· Aug 5, 2010, 14:41 UTC · re: Jonathan Nieder · lore

Re: git merge - "both added" conflict resolution

On Wed, Aug 4, 2010 at 7:36 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 10 quoted lines
> Eugene Sajine wrote:
>
>> So, I'm removing all conflict markers and removing the incoming line
>> with the property value=projectOne leaving it as projectTwo.
>> This effectively means that there is no changes in build.xml for git.
>> And I'm stuck because i cannot add file, that is not changed
>
> Sorry I wasn’t clear before.  Could you give output from attempting
> to add the file?  It is supposed to work.
>

There is no output after I add build.xml with resolved conflicts. When i do git status build.xml doesn't show up there.

I tried another way: After i have a conflict i add the build.xml withtout resolving conflicts. Then I unstage it - it's status changes from "both added: " to "modified" Then i can resolve the conflict, which means build.xml returns to it's last committed state. But then i'm back to square one as build.xml is not showing in changes, so i cannot add it and i still cannot commit because of partial commit.

Thanks, Eugene

Eugene Sajine· Aug 6, 2010, 14:57 UTC · re: Eugene Sajine · lore

Re: git merge - "both added" conflict resolution

On Thu, Aug 5, 2010 at 10:41 AM, Eugene Sajine <euguess@gmail.com> wrote:
Show 28 quoted lines
> On Wed, Aug 4, 2010 at 7:36 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Eugene Sajine wrote:
>>
>>> So, I'm removing all conflict markers and removing the incoming line
>>> with the property value=projectOne leaving it as projectTwo.
>>> This effectively means that there is no changes in build.xml for git.
>>> And I'm stuck because i cannot add file, that is not changed
>>
>> Sorry I wasn’t clear before.  Could you give output from attempting
>> to add the file?  It is supposed to work.
>>
>
>
> There is no output after I add build.xml with resolved conflicts. When
> i do git status build.xml doesn't show up there.
>
> I tried another way:
> After i have a conflict i add the build.xml withtout resolving
> conflicts. Then I unstage it - it's status changes from "both added: "
> to "modified"
> Then i can resolve the conflict, which means build.xml returns to it's
> last committed state. But then i'm back to square one as build.xml is
> not showing in changes, so i cannot add it and i still cannot commit
> because of partial commit.
>
> Thanks,
> Eugene
>

When i experimenting with it with test repos - it is working OK. So, i believe it will be very difficult to reproduce.

I'm still having this problem with two repos of mine, but as it is not common, i gotta dig deeper there.

Thanks, Eugene

← back to recent threads