How do I resolve a conflict after git pull?

101,505

Solution 1

You don't need mergetool for this. It can be resolved pretty easily manually.

Your conflict is that your local commits added a file, vision_problem_8.h, that a remote commit also created, by a rename from vignette_generator_mashed.h. If you run ls -l vision_problem_8.h* you will probably see multiple versions of this file that git has preserved for you. One of them will be yours, another of them will be the remote version. You can use an editor or whatever tools you like to resolve the conflicting contents. When you're done, git add the affected files and commit to complete the merge.

If you just want to use the remote commit's version, then you can just move the copy that you didn't write into place and git add it.


Regarding the merge tools, have a look at git help mergetool. Basically, it's going to try running each of the included possibilities until it finds one, or use one you have explicitly configured.

Solution 2

I think you just forgot "-t" switch at your command line. According git help page it stands for "-t , --tool=" so it makes what you intended to.

Try:

git mergetool -t gvimdiff

Of course you may use your prefered merge tool instead of mine gvimdiff, meld is great too...

Solution 3

If you run your merge from a subdirectory of your project, git will run the merge for your whole project. However, mergetool can only see (and merge) files in or below the working directory. So, if this scenario occurs, make sure you are trying to run your conflict resolution from the top-level directory in your project.

Solution 4

What if I simply want the version from git pull to overwrite everything? If you want just that you should use:

 git fetch
 git reset --hard origin/your-branch-name
Share:
101,505
Tim
Author by

Tim

Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.

Updated on July 09, 2022

Comments

  • Tim
    Tim almost 2 years

    I have to solve some conflict after a git pull.

    $ git pull
    CONFLICT (rename/add): Renamed vignette_generator_mashed.h->vision_problem_8.h in 49423dd0d47abe6d839a783b5517bdfd200a202f. vision_problem_8.h added in HEAD
    Added as vision_problem_8.h~HEAD_1 instead
    Removed vignette_generator_cross_square.cc
    Automatic merge failed; fix conflicts and then commit the result.
    

    So I googled it a bit, and found people saying using git mergetool. But here is what I got:

    $ git mergetool
    merge tool candidates: meld kdiff3 tkdiff xxdiff meld gvimdiff emerge opendiff emerge vimdiff
    No files need merging
    $ git mergetool opendiff
    merge tool candidates: meld kdiff3 tkdiff xxdiff meld gvimdiff emerge opendiff emerge vimdiff
    opendiff: file not found
    

    So does it mean I have to install something?

    What if I simply want the version from git pull to overwrite everything?

  • Tim
    Tim over 14 years
    Thanks! You help me solve the problem. May I still ask what is wrong with my mergetool? Thanks and regards!
  • Cesar
    Cesar over 14 years
    Most likely you don't have your mergetool configured. Use git config --global mergetool.[tool].cmd = [command-line call] You can use many diff tools like kdiff3, tkdiff, xxdiff or many others. See gitguru.com/2009/02/22/integrating-git-with-a-visual-merge-t‌​ool
  • Stewart
    Stewart about 6 years
    This would be a better answer if there was some explanation of what the switch -t actually does, and why it solves the problem.
  • mano2a0c40
    mano2a0c40 about 6 years
    @Stewart Done. Thanks for the insight!
  • saferJo
    saferJo about 6 years
    yee it should be hard reset.