Only attempt to create Git credentials when a workspace dir is present.

This command is used during form validation and launching a Git command.  The problem
is that for HTTP-based URLs during the form validation, there's no workspace directory.
As a result, the credentials store is attempted to created in the directory in which
Jenkins was started (i.e. /), causing accesses to .git/config, which are done when
storing credential files, to fail.

See: https://issues.jenkins-ci.org/browse/JENKINS-21016