Question: When cloning git repositories in automated tools - web front ends, CI systems, sometimes the git clone invocation opens up a prompt asking for the username and password (for example, when cloning a non-existent Github repo or on a new node missing ssh keys).

How do I make git just fail (preferably with a sensible error message and exit code) instead of waiting for the server process to give it a username and password?

Answer: 
In git version 2.3 there's an environment variable `GIT_TERMINAL_PROMPT` which when set to `0` will disable prompting for credentials.

You can get more info about it in `man git` (after updating to git version `2.3`) or in [this blog post on github](https://github.com/blog/1957-git-2-3-has-been-released).

Examples:

* `git clone https://github.com/some/non-existing-repo` will prompt for username & password
* `GIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existing-repo` will fail without prompting for username & password
When you only have control over the git configuration:

```
git config --global credential.helper '!f() { echo quit=1; }; f'

```

Gives

```
$ git clone https://github.com/edx/drf-extensions.git/
Cloning into 'drf-extensions'...
fatal: credential helper '!f() { echo quit=1; }; f' told us to quit

```

The [idea](https://github.com/gitster/git/commit/86362f7205a31188846de0aed94620c1f0776931#diff-34bca67031e9e8c12799a2252004d3f6R294) comes from the original committer of `GIT_TERMINAL_PROMPT` after following @user243345's link.