Christopher Pickslay
Christopher Pickslay

Reputation: 17762

git mergetool reports "No files need merging"

For some reason lately, every time I pull and get a merge conflict, running git mergetool reports "No files need merging":

$ git pull
First, rewinding head to replay your work on top of it...
Applying: replaced home button with Cancel
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
error: Your local changes to the following files would be overwritten by merge:
    Classes/Controllers/HomeController.m
Please, commit your changes or stash them before you can merge.
Aborting
Failed to merge in the changes.
Patch failed at 0002 moved rollback into cancel button in log watching

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

$ git mergetool
No files need merging

If I run git rebase --abort and pull again, either the same thing happens on a different conflict, or the pull succeeds with no merge conflict. There are no remote changes between these pulls, so it's not as though the conflict went away.

Here's how this branch and the remote are configured:

[branch "develop"]
        remote = origin
        merge = refs/heads/develop
        rebase = true
[remote "origin"]
        url = <my repo url>
        fetch = +refs/heads/*:refs/remotes/origin/*

Upvotes: 51

Views: 23888

Answers (7)

Josh
Josh

Reputation: 2222

This fixed it for me:
git mergetool .

I found this fix here

Upvotes: 45

mitch
mitch

Reputation: 436

Could it be that you must first run merge? Then if there are merge conflicts to resolve, you can run mergetool. But until there are created as the results of an incomplete merge, I think mergetool will simply report there is nothing to merge.

Upvotes: 0

TrueWill
TrueWill

Reputation: 25523

In my case the issue was that I had another console window open and was running the application (based on create-react-app, with hot reloading) in that window.

Killing the process and closing the other window, then aborting the rebase and retrying worked for me.

Upvotes: 0

AbstractProblemFactory
AbstractProblemFactory

Reputation: 9811

Trivial solution

which worked for me: Git creates some merge related files in the very same directory where the conflicted file is, so remember to run git mergetool in correct path.

Upvotes: 12

lijinma
lijinma

Reputation: 2942

Solution 1:

$git config --global core.trustctime false

If false, the ctime differences between the index and the working copy are ignored; useful when the inode change time is regularly modified by something outside Git (file system crawlers and some backup systems). and core.trustctime is true by default.

Solution 2: just:

$git rebase --skip

It's OK for you to skip it

Upvotes: 5

Adam Dymitruk
Adam Dymitruk

Reputation: 129546

Merge tools are better at resolving conflicts than stock git. It can't be too opinionated. For example Beyond Compare is syntax aware and will do a lot for you. If you have it configured right, you can just compile and run your solution to test. If it's all good, then just git add -A and git rebase --continue. What you are experiencing is normal. Double check your "trust mergetool exit code" setting:

git config --global mergetool.trustExitCode true

Note: the -A option in git add will stage all changes including deletions and new, untracked files.

Upvotes: 0

Christopher Pickslay
Christopher Pickslay

Reputation: 17762

It looks like my problem had to do with file timestamps. Thanks to this SO answer suggested by Mark Longair, the following setting fixed it for me:

git config --global core.trustctime false

Upvotes: 17

Related Questions