git clone - fail instead of prompting for credentials
Solution 1:
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.
Examples:
git clone https://github.com/some/non-existing-repo
will prompt for username & passwordGIT_TERMINAL_PROMPT=0 git clone https://github.com/some/non-existing-repo
will fail without prompting for username & password
Solution 2:
If you are using ssh authentication, and on linux, then you can create an ssh command replacement to disable this.
Create a file called "sshnoprompt.sh" with:
ssh -oBatchMode=yes $@
Make this file executable with chmod +x sshnoprompt.sh
Then when starting git:
GIT_SSH="sshnoprompt.sh" 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.