In this article you see that t how you can save username and password in Git and how you can save credentials in git for pull and push changes,
While working with git you always have to provide your credentials for connecting a remote repository with Git’s local repository. To avoid this hassle, Git enables you to store a username and password locally and globally to be accessible to all current project users.
Git does not save usernames and passwords by default, as this information is usually sensitive and could pose a security risk. Instead, you have a few options to securely authenticate with your Git repository:
SSH Key authentication: This method uses a public/private key pair to authenticate with the Git repository. The private key is stored on your local machine, while the public key is added to your Git repository account. To set up SSH key authentication, you can follow these steps:
ssh-keygen
command.
Credential Manager: Most Git clients provide a way to securely store your credentials using a built-in or third-party credential manager. This will cache your username and password for a specified amount of time, so you won’t have to enter them for every Git operation. To use a credential manager, follow these steps:
Store credentials permanently:
git config --global credential.helper <helper>
Replace <helper>
with the appropriate credential helper for your Git client.
Connect the local repository with the remote repository:
git clone <repository_url>
Replace <repository_url>
with the URL of your remote repository.
cd <repository_name>
Replace <repository_name> with the name of your local repository.
With these steps, your Git operations will be more convenient, as your credentials will be securely stored, and you can easily connect to your remote repository.
Note: When using either of these methods, it's important to ensure that your computer is secure and that you take measures to protect your private keys and cached credentials.