This is all a lot simpler is you use ssh keys and ssh agent. Or on
Windows, using putty for the ssh utility and pageant for the agent. An
ssh key agent will stay in memory. The user provides their passphrase
to unlock the key on startup and then the agent hands out the key on
request. In msysGit, if you set the environment variable GIT_SSH=plink
or %ProgramFiles%\TortoiseSVN\bin\TortoisePlink.exe if you have it
then this will fetch the pre-unlocked key from pageant when necessary.
The puttygen utility can create ssh keys or import ssh keys into a
format that pageant can use.
If you must -- there is 'git gui--askpass' which will throw up a
dialog to ask for the password then emits it to stdout. Text mode
password utilities tend to try to avoid stdin and ensure they really
are talking to the user. Usually 'expect' gets used to work around
these in the absence of something better like ssh keys.