With Git version 1.7.9 and later, there is a neat mechanism in Git to avoid having to type your password all the time for HTTP / HTTPS, called credential helpers.
you can just use one of the following credential helpers:
git config --global credential.helper cache
This command will help git to keep your credentials in cache memory for 15 minutes(default).
git config --global credential.helper "cache --timeout=3600"
With this, you can set your time limit so that it can stay in cache memory.
if you're on Mac OS X and used Homebrew to install Git, you can use the native Mac OS X keystore with:
git config --global credential.helper osxkeychain
For wincred
git config --global credential. helper wincred # obsolete
For windows
git config --global credential.helper manager
For Linux, you can use gnome-keyring
With Git versions before 1.7.9, this more secure option is not available, and you'll need to change the URL that your origin remote uses to include the password in this fashion:
git config remote.origin.url https://you:[email protected]/you/example.git
This command will store the credential in a plain text in your git directory.
With any Git version(since version 0.99)
An alternative approach is to put your username and password in your ~/.netrc file, although, as with keeping the password in the remote URL, this means that your password will be stored on the disk in plain text and is thus less secure and not recommended.
Even if you want to go with this approach follow this in command in ~/.netrc:
machine <hostname> login <username> password <password>
Also, don’t forget to set restrictive file system permissions on that file:
chmod 600 ~/.netrc
Note:
On Windows, this file should be called _netrc, and you may need to define the %HOME% environment variable
For more details:-https://git-scm.com/docs/git-credential-cache