It is more popular to use an ssh key instead of a password when automating a git clone from a guest OS. But if you do need to specify the password directly into the console command, it takes this form:
$ git clone https://<user>:<password>@<gitserver>/<path>/<repo>.git
Which works fine if the password is plaintext, but if it has special characters like an exclamation mark, you need to use percent encoding which is often called URL encoding.
! # $ & ' ( ) * + , / : ; = ? @ [ ] %21 %23 %24 %26 %27 %28 %29 %2A %2B %2C %2F %3A %3B %3D %3F %40 %5B %5D
For example, using the credentials myuser/password! to a github repository would look like:
$ git clone https://myuser:password%21@github.com/myuser/repo.git
If this is a folder accessible to anyone else in your group, make sure you don’t leave your credentials in the remote URL.
# check remote URL, ensure password is not still present git remote -v # if you need to remove the password, just leave the user id git remote set-url origin https://myuser@github.com/myuser.repo.git
Cached Credentials
If you are actively working on this repository and do not want to supply this password every time you perform a push, you can specify the use of a cache and the number of seconds it is valid:
$ git config --global credential.helper 'cache --timeout=3600'
If you are using git on Windows and want to use the Windows credential manager:
> git config --global credential.helper manager
Or are on Windows and have issues with the credential manager then you can use a simple file store instead.
> git config --global --unset credential.helper > git config --global credential.helper "store %USERPROFILE%\.git-config"
Proxy
If you are accessing a remote web repository and your git client needs to go through a proxy such as Squid.
git config --global http.proxy http://<squid>:3128
REFERENCES
https://gist.github.com/evantoli/f8c23a37eb3558ab8765 (git config options)
http://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use
https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
https://stackoverflow.com/questions/17659206/git-push-results-in-authentication-failed (expired credentials, enter new)
NOTES
Base client settings
git config --global user.email "<email@host>" git config --global user.name "<user name>" git config --global push.default simple git config --global core.editor vim git config --global core.autocrlf false git config --global http.proxy http://<squid>:3128 git config --list git config --global --list
To remove credential helper if credentials changed
git config --global --unset-all credential.helper git config --unset-all credential.helper
Windows credential manager
> git config --global credential.helper manager > git credential-manager version
Expired credentials, unset credentials cache
git config --global --unset credential.helper