To solve this problem, github recommends Connecting over HTTPS.
Git's documentation discuss how to how to do exactly that using gitcredentials.
Solution 1
Static configuration of usernames for a given authentication context.
https:
You will find the details in the documentation.
Solution 2
Use credential helpers to cache password (in memory for a short period of time).
git config
Solution 3
Use credential helpers to store password (indefinitely on disk).
git config --global credential.helper 'store --file ~/.my-credentials'
You can find where the credential will be saved (If not set explicitly with --file) in the documentation.
If not set explicitly with --file, there are two files where
git-credential-store will search for credentials in order of
precedence:
~/.git-credentials
User-specific credentials file. $XDG_CONFIG_HOME/git/credentials
Second user-specific credentials file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/credentials will be used. Any
credentials stored in this file will not be used if ~/.git-credentials
has a matching credential as well. It is a good idea not to create
this file if you sometimes use older versions of Git that do not
support it.
P.S.
To address the concern:
your password is going to be stored completely unencrypted ("as is")
at ~/.git-credentials.
You can always encrypt the file and decrypt it before using.