Skip to content

Instantly share code, notes, and snippets.

@polbins
Last active June 20, 2022 02:50
Show Gist options
  • Save polbins/42a39cb3234e3acfba79 to your computer and use it in GitHub Desktop.
Save polbins/42a39cb3234e3acfba79 to your computer and use it in GitHub Desktop.
Android Studio as default Git Diff Tool

Create Android Studio Command-line Launcher

  1. Open Android Studio
  2. Go to: Tools > Create Command-line Launcher
  3. Leave as default, Press OK

Configure Git to use Android Studio as default Diff Tool

  1. Add the following lines to your .gitconfig
[merge]
   tool = studio
[mergetool "studio"]
   cmd = studio 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
[diff]
   tool = studio
[difftool "studio"]
   cmd = studio diff $(cd $(dirname "$LOCAL") && pwd)/$(basename "$LOCAL") $(cd $(dirname "$REMOTE") && pwd)/$(basename "$REMOTE")

Sources

https://www.jetbrains.com/idea/help/running-intellij-idea-as-a-diff-or-merge-command-line-tool.html http://brian.pontarelli.com/2013/10/25/using-idea-for-git-merging-and-diffing/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment