How to auto-configure git merge tool based on what is available on current machine?

I am working a many system and at least on some of them my home directory is stored on NIS, so I do share that same preferences.

I do want to write a small bash script which I can include inside ~/.bash_profile which will configure the best diff tool which is already installed on current machine.

  • Change GIT repository to shared
  • git: hash autocomplete
  • Bash script print to a programs prompt
  • Git in PyCharm using a pre-existing repository
  • Git Bash Slow on Windows 10
  • How to write a shell script that checks if git repository is up to date?
  • The rule is simple, I have to check which command line diff tools are available and configure git to use the first one that I found.

    Side note: On one linux machine I discovered that there is and ENV variable __git_mergetools_common=$'diffuse ecmerge emerge kdiff3 meld opendiff\n\t\t\ttkdiff vimdiff gvimdiff xxdiff araxis p4merge\n' – I have no idea what is this used for, but it looks interesting.

  • Git rebase --preserve-merges fails
  • NetBeans and Git: I did install Git plugin but does not connect to repo after initializing, nor adds files
  • How to Manually Deploy a Rails App with Git
  • svn-checkout from a GIT repository
  • Can you get a word-diff with `git log`?
  • Get a List of all Pushes with Git
  • One Solution collect form web for “How to auto-configure git merge tool based on what is available on current machine?”

    Probably the easiest answer is to write a bash script that runs as the diff program, and selects the best available actual diff program each time.

    Git Baby is a git and github fan, let's start git clone.