If you 'pull' and another developer has made a change to the same file
you have, you might get a message like this:
    $ git merge origin/master  ;# can happen with 'git pull', 'git rebase' too
    Auto-merged src/Makefile
    CONFLICT (content): Merge conflict in src/Makefile
    Removed src/hal/classicladder/arrays.h
    Automatic merge failed; fix conflicts and then commit the result.

This is not about permissions or ownership of the file.  This is because
two developers made a change to the same part of the same file.

In my case, I'd deleted a line right by the one that Moses committed.
In the resulting Makefile, it looked like this (Use your editor's find
command and search for "<<<"):

    <<<<<<< HEAD:src/Makefile
    $(FILE) ../*.png ../*.gif $(DESTDIR)$(sysconfdir)/emc2
    =======
    $(FILE) ../docs/UPDATING $(DESTDIR)$(docsdir)/UPDATING
    $(FILE) ../*.png ../*.gif $(DESTDIR)$(datadir)/emc
    >>>>>>> origin/master:src/Makefile

that shows that in my copy there was the one line shown; in the 'origin'
copy there are the two lines.  I know that Moses' change was to modify
the installation path of those files, so I left the line
    $(FILE) ../*.png ../*.gif $(DESTDIR)$(datadir)/emc
and deleted the others, including the merge markers <<<, ===, and >>>.

(So far, this is almost exactly like resolving a conflict in cvs)

Now, you have to tell git that the conflict is resolved:
    $ git add Makefile
    $ git commit
    (you can accept the message without editing)

If you've gotten yourself lost by moving files around, you can give up
on the merge instead of committing:
    $ git reset --hard
this goes back to the last change you had committed; As long as you
had committed before you pulled, no work is lost.  BUT IF YOU HAVE NOT
COMMITTED, THIS COMMAND WILL LOSE DATA.

In CVS, you could
    $ rm Makefile
    $ cvs up Makefile
    edit Makefile to restore your own edits
to use the "other" Makefile as a starting point to remake your own
changes.  You can do this in git too, but you might have to spend 20
minutes in the manual to find out how to write it:
    $ git cat-file blob :3:src/Makefile > Makefile  ;# in directory src/
(yeah, that's nice and convenient)

If your original error message said
    src/Makefile: needs update
    fatal: Entry 'src/Makefile' not uptodate. Cannot merge.
    Merge with strategy recursive failed.
then it's because you didn't commit before you merged.  If you don't
want to commit now, you can stash (but this still doesn't save you from
a conflict..):
    $ git stash
    Saved working directory and index state "WIP on master: 1f28be1...
    $ git merge origin/master
    $ git stash apply
    Auto-merged src/Makefile
    CONFLICT (content): Merge conflict in src/Makefile

Jeff

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to