Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
We have a multi-server Jenkins set up, which annoyingly sits waiting for a prompt until killed if it runs on a new server missing the ssh keys - a way to configure that it will simply fail with a message and non-zero exit code would be useful. – Danny Staple Dec 2 '13 at 14:46
If a catch all "batch" mode could be used to disallow prompting for host keys too - this would be ideal. – Danny Staple Dec 2 '13 at 14:55
These are both related - trying to piece them together -…,…. – Danny Staple Dec 2 '13 at 15:06
up vote 2 down vote accepted

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.


  • git clone will prompt for username & password
  • GIT_TERMINAL_PROMPT=0 git clone will fail without prompting for username & password
share|improve this answer

Depending on how you're running git, redirecting stdin or stdout so that they are not connected to terminals will stop git from prompting for details and just cause it to error.

This would also allow you to surface errors (or at least logs) to the webservice.

share|improve this answer
How exactly would I go about doing this? Trying to accomplish this in Bash first, both </dev/null and nohup .. & don't seem to work. – Tin Tvrtković Oct 15 '13 at 21:56

If you are using ssh authentication, and on linux, then you can create an ssh command replacement to disable this.

Create a file called "" with:

ssh -oBatchMode=yes $@

Make this file executable with chmod +x

Then when starting git:

GIT_SSH="" git clone foo@dummyserver:not_a_repo

And it will not allow any interactive git prompts or questions - it shouldn't be able to ask the user for anything.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.