如何从命令行使用PyCharm作为GIT差异工具? [英] How to use PyCharm as a GIT diff tool from the command line?

查看:116
本文介绍了如何从命令行使用PyCharm作为GIT差异工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

On the PyCharm Help Website I see you can use PyCharm as a diff tool from the Command Line to compare two files. That's awesome! However is there a way to take it a step further and use it as a git diff tool.

因此,我只需键入 pycharm diff file_name.py 即可获得GIT差异,就像您在PyCharm上时一样,设置了GIT集成并按 CTRL + D 查看差异.

So I can just type pycharm diff file_name.py and get the GIT differences same way you would if you were on PyCharm have setup the GIT integration and press CTRL + D to see the differences.

推荐答案

是的.

首先,您需要启用命令行启动器:

First you need to enable the command-line launcher:

要启用从命令行调用PyCharm操作,请遵循这些步骤

To enable invoking PyCharm operations from the command line, follow these steps

  • macOS UNIX 上:

  1. 确保PyCharm正在运行.
  2. 在在主菜单中,选择工具|创建命令行启动器.对话框创建启动器脚本随即打开,其中包含建议的路径和名称启动器脚本.您可以接受默认值,也可以指定自己的路径.记下它,稍后再用.
  3. 在PyCharm之外,将启动脚本的路径和名称添加到您的路径中.
  1. Make sure PyCharm is running.
  2. On the main menu, choose Tools | Create Command-line Launcher. The dialog box Create Launcher Script opens, with the suggested path and name of the launcher script. You can accept default, or specify your own path. Make notice of it, as you'll need it later.
  3. Outside of PyCharm, add the path and name of the launcher script to your path.

  • Windows 上:

    1. 指定PyCharm可执行文件的位置在 Path 系统环境变量中.在这种情况下,您将能够从以下位置调用PyCharm可执行文件和其他PyCharm命令任何目录.
    1. Specify the location of the PyCharm executable in the Path system environment variable. In this case, you will be able to invoke the PyCharm executable and other PyCharm commands from any directory.

  • https://www.jetbrains.com/help/pycharm/running-pycharm-as-a-diff-or-merge-command-line-tool.html

    然后将以下行添加到您的〜/.gitconfig :

    Then add the following lines to your ~/.gitconfig:

    [diff]
            tool = pycharm
    [difftool "pycharm"]
            cmd = /usr/local/bin/charm diff "$LOCAL" "$REMOTE" && echo "Press enter to continue..." && read
    [merge]
            tool = pycharm
    [mergetool "pycharm"]
            cmd = /usr/local/bin/charm merge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
            keepBackup = false
    

    (对于Windows用户,这些详细信息可能会略有不同)

    (for Windows users these details might be slightly different)

    这篇关于如何从命令行使用PyCharm作为GIT差异工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆