Skip to content

Instantly share code, notes, and snippets.

@idefav
Forked from ffittschen/gitconfig.md
Created July 14, 2023 02:13
Show Gist options
  • Select an option

  • Save idefav/2bd1ed7683e127549b7df4e73b929bf6 to your computer and use it in GitHub Desktop.

Select an option

Save idefav/2bd1ed7683e127549b7df4e73b929bf6 to your computer and use it in GitHub Desktop.

Revisions

  1. @ffittschen ffittschen revised this gist Jun 24, 2016. 1 changed file with 21 additions and 14 deletions.
    35 changes: 21 additions & 14 deletions gitconfig.md
    Original file line number Diff line number Diff line change
    @@ -1,25 +1,32 @@
    # Use IntelliJ or WebStorm as git mergetool with SourceTree
    # Use IntelliJ or WebStorm as git mergetool
    ## Configure Sourcetree

    The merge tool that ships with JetBrain's IntelliJ IDEA or WebStorm is really awesome and way better than `FileMerge`. It is quite simple to configure SourceTree to use it as the default mergetool:

    1. Open the `~/.gitconfig` file with your favorite editor
    2. Find the following lines:
    1. Open the SourceTree preferences and select the `Diff` tab
    2. Choose `Custom` both as `Visual Diff Tool` and as `Merge Tool`
    3. Paste the following commands into the textfields:

    ```
    [difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path =
    [mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
    ```
    - **Diff Command:** `/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea diff`
    - **Arguments:** `$(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")`

    - **Merge Command:** `/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea merge`
    - **Arguments:** `$(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE") $(cd $(dirname "$BASE") && pwd)/$(basename "$BASE") $(cd $(dirname "$MERGED") && pwd)/$(basename "$MERGED")`
    1. Close the settings. Happy merging!

    3. Edit the lines to look like this:

    ## Git in general
    To manually change the mergetool for git in general follow these steps:

    1. Open the `~/.gitconfig` file with your favorite editor
    1. Add these lines somewhere in the config:

    ```
    [difftool "sourcetree"]
    [merge]
    tool = intellij
    [difftool "intellij"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
    [mergetool "sourcetree"]
    [mergetool "intellij"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
    trustExitCode = true
    ```
  2. @ffittschen ffittschen revised this gist Jun 24, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions gitconfig.md
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,9 @@ The merge tool that ships with JetBrain's IntelliJ IDEA or WebStorm is really aw
    trustExitCode = true
    ```
    ## Downsides
    It takes a few more seconds to launch the IntelliJ merge tool than to launch FileMerge, but it is definitely worth waiting.
    ## Credits
    Based on this article on coderwall: https://coderwall.com/p/gc_hqw/use-intellij-or-webstorm-as-your-git-diff-tool-even-on-windows
  3. @ffittschen ffittschen revised this gist Jun 24, 2016. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions gitconfig.md
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@ The merge tool that ships with JetBrain's IntelliJ IDEA or WebStorm is really aw

    1. Open the `~/.gitconfig` file with your favorite editor
    2. Find the following lines:

    ```
    [difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    @@ -12,7 +13,9 @@ The merge tool that ships with JetBrain's IntelliJ IDEA or WebStorm is really aw
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
    ```
    3. Edit the lines to look like this:
    ```
    [difftool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
  4. @ffittschen ffittschen revised this gist Jun 24, 2016. 1 changed file with 15 additions and 15 deletions.
    30 changes: 15 additions & 15 deletions gitconfig.md
    Original file line number Diff line number Diff line change
    @@ -4,21 +4,21 @@ The merge tool that ships with JetBrain's IntelliJ IDEA or WebStorm is really aw

    1. Open the `~/.gitconfig` file with your favorite editor
    2. Find the following lines:
    ```
    [difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path =
    [mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
    ```
    ```
    [difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path =
    [mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
    ```
    3. Edit the lines to look like this:
    ```
    [difftool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
    [mergetool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
    trustExitCode = true
    ```
    ```
    [difftool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
    [mergetool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
    trustExitCode = true
    ```
    Based on this article on coderwall: https://coderwall.com/p/gc_hqw/use-intellij-or-webstorm-as-your-git-diff-tool-even-on-windows
  5. @ffittschen ffittschen created this gist Jun 24, 2016.
    24 changes: 24 additions & 0 deletions gitconfig.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    # Use IntelliJ or WebStorm as git mergetool with SourceTree

    The merge tool that ships with JetBrain's IntelliJ IDEA or WebStorm is really awesome and way better than `FileMerge`. It is quite simple to configure SourceTree to use it as the default mergetool:

    1. Open the `~/.gitconfig` file with your favorite editor
    2. Find the following lines:
    ```
    [difftool "sourcetree"]
    cmd = opendiff \"$LOCAL\" \"$REMOTE\"
    path =
    [mergetool "sourcetree"]
    cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
    trustExitCode = true
    ```
    3. Edit the lines to look like this:
    ```
    [difftool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea diff $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\")
    [mergetool "sourcetree"]
    cmd = /Applications/IntelliJ\\ IDEA.app/Contents/MacOS/idea merge $(cd $(dirname \"$LOCAL\") && pwd)/$(basename \"$LOCAL\") $(cd $(dirname \"$REMOTE\") && pwd)/$(basename \"$REMOTE\") $(cd $(dirname \"$BASE\") && pwd)/$(basename \"$BASE\") $(cd $(dirname \"$MERGED\") && pwd)/$(basename \"$MERGED\")
    trustExitCode = true
    ```

    Based on this article on coderwall: https://coderwall.com/p/gc_hqw/use-intellij-or-webstorm-as-your-git-diff-tool-even-on-windows