git config --global credential.helper cache
… which tells git to keep your password cached in memory for (by default) 15 minutes. You can set a longer timeout with:
git config --global credential.helper "cache --timeout=3600"
More useful links:
https://confluence.atlassian.com/bitbucketserver/permanently-authenticating-with-git-repositories-776639846.html
Using the .netrc file
The .netrc file is a mechanism that allows you to specify which credentials to use for which server.This method allows you to avoid entering a username and password every time you push to or pull from Git, but your Git password is stored in plain text.
You can store your credentials using the following command
git config credential.helper store
git push http://example.com/repo.git
# Now type username and password and it should be saved by git.