git difftool runs git diff

后端 未结 2 783
小鲜肉
小鲜肉 2020-12-19 13:51

I am obviously overlooking something very simple here, but I am not seeing it. The command

webstorm diff ~/test.txt ~/test2.txt

runs the J

相关标签:
2条回答
  • 2020-12-19 14:09

    I just had the same problem. My git diftool configuration has been set up in my ~/.gitconfig and has been working fine, but today weirdly git difftool worked in one repo but ran git diff in another.

    Fix: I updated from git 2.11.0 to git 2.11.1 and the problem seems to have gone away.

    The git 2.11.1 release notes mention fixing a difftool-related regression. The described problem isn't what I was seeing, but maybe the fix fixed it anyway.

    0 讨论(0)
  • 2020-12-19 14:18

    Run:

    GIT_TRACE=1 git difftool --tool-help
    

    to print a list of diff tools that may be used with --tool, and which are not available.


    Secondly I believe the following simplified example may work better:

    [difftool "webstorm"]
      cmd = webstorm diff "$LOCAL" "$REMOTE"
    

    Or by specifying the path to the binary or script, e.g.

    [difftool]
      prompt = NO
      external = /usr/local/bin/diffmerge
    

    Check the diff configuration by:

    git config --get-regex diff
    

    Or more specifically (replace webstorm with your tool name):

    git config --get difftool.webstorm.cmd
    

    If still doesn't work, test it on the new repository, e.g. by following these commands:

    mkdir ~/git_test && cd ~/git_test
    git init && touch file && git add file && git commit -m'Adds file' -a
    echo changed >> file
    GIT_TRACE=1 git difftool
    

    If above works, then make sure your repository config doesn't have anything unexpected, e.g.

    more "$(git rev-parse --show-toplevel)"/.git/config
    

    If you're in merge state (check by git status), you need to use mergetool instead, e.g.

    git mergetool
    

    Add -t tool to specify which tool. List available by git mergetool --tool-help.


    See also man git-difftool:

    CONFIG VARIABLES
           git difftool falls back to git mergetool config variables when the difftool equivalents have not been
           defined.
    
           diff.tool
               The default diff tool to use.
    
           diff.guitool
               The default diff tool to use when --gui is specified.
    
           difftool.<tool>.path
               Override the path for the given tool. This is useful in case your tool is not in the PATH.
    
           difftool.<tool>.cmd
               Specify the command to invoke the specified diff tool.
    
               See the --tool=<tool> option above for more details.
    
           difftool.prompt
               Prompt before each invocation of the diff tool.
    
    0 讨论(0)
提交回复
热议问题