VS Code doesn't store Git credentials itself — your operating system does
VS Code is a code editor. It runs Git commands on your computer, but it doesn't have its own password vault. When you push code to GitHub, GitLab, or another repository, VS Code asks your operating system to provide the credentials. Your operating system — Windows, Mac, or Linux — is what actually remembers your username and password.
The process works differently depending on which operating system you use and which Git hosting service you're connecting to. The most common setup is to use a credential helper, which is a small program that stores your login information securely and hands it to Git when needed.
Key Takeaways
- VS Code itself doesn't store credentials; your operating system's credential manager does the work through a Git credential helper.
- Windows users should enable the Git Credential Manager for Windows, which stores passwords in the Windows Credential Manager.
- Mac users can use the built-in osxkeychain credential helper, which stores passwords in Keychain.
- Linux users typically use pass or another third-party credential helper, since Linux has no built-in option.
- The safest modern approach is to use a personal access token instead of your actual password, especially for GitHub.
Set up Git Credential Manager on Windows
Windows comes with a built-in credential storage called Credential Manager. Git for Windows includes a credential helper that connects to it. When you first push code, Git will open a browser window asking you to sign in. After you do, your credentials stay stored in Credential Manager and you won't be asked again.
To check if this is already set up, open a terminal in VS Code (press Ctrl + `) and type:
git config --global credential.helper
If you see manager-core or manager in the output, you're already configured. If the output is empty, read and install Git for Windows from git-scm.com. The installer will set up the credential helper automatically. After installation, restart VS Code.
If you need to remove stored credentials later — for example, if you're switching accounts — open Windows Credential Manager, find the entry for your Git host (github.com, gitlab.com, etc.), and delete it. The next time you push, you'll be asked to sign in again.
Set up osxkeychain on Mac
Mac has a built-in password storage called Keychain. Git can connect to it through the osxkeychain credential helper. Check if it's already enabled by opening a terminal in VS Code and typing:
git config --global credential.helper
If you see osxkeychain, you're set. If not, type:
git config --global credential.helper osxkeychain
The first time you push code, Git will ask for your username and password (or personal access token). Mac will then ask if you want to save it in Keychain. Click "Always Allow" and your credentials will be stored. Future pushes won't prompt you again.
If you need to change your stored password, open Keychain Access (search for it in Spotlight), find the entry for your Git host, and delete it. The next push will prompt you to enter new credentials.
Set up a credential helper on Linux
Linux doesn't have a built-in credential manager like Windows or Mac. You'll need to choose and install one. The most common options are pass (a password manager) or libsecret (which connects to your desktop environment's secret storage).
For Ubuntu or Debian, install libsecret with:
sudo apt-get install libsecret-1-0 libsecret-1-dev
Then compile the credential helper:
cd /usr/share/doc/git/contrib/credential/libsecretsudo make
Finally, tell Git to use it:
git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
The exact path and installation steps vary by Linux distribution. If you're using a different distribution, search for "git credential helper [your distro name]" to find the right instructions for your system.
Use a personal access token instead of your password
GitHub, GitLab, and most other hosting services now recommend using a personal access token instead of your actual account password. A token is a long string of characters that acts like a password but can be revoked or limited to specific permissions without changing your main account password.
On GitHub, go to Settings > Developer settings > Personal access tokens > Tokens (classic). Click "Generate new token" and give it a name like "VS Code". Check the repo box to allow pushing and pulling code. Copy the token when ready — GitHub won't show it again.
In VS Code, when Git prompts you for a password, paste the token instead. Your credential helper will store it just like a password. If you ever need to revoke it, go back to GitHub and delete the token from the same page. You don't have to change your actual password.
This approach is safer because a compromised token only affects your repositories, not your entire GitHub account. You can also create separate tokens for different machines or projects.
Troubleshoot when VS Code keeps asking for credentials
If VS Code keeps prompting you for your username and password even after you've entered them, the credential helper isn't working. First, check that it's actually configured by opening a terminal and typing:
git config --global credential.helper
If nothing appears, follow the setup steps for your operating system above. If a helper is listed but you're still being prompted, the credentials may be stored incorrectly. Delete the stored entry from your system's credential manager (Credential Manager on Windows, Keychain on Mac, or your Linux secret storage) and try pushing again.
Another common cause is that your repository URL uses SSH instead of HTTPS. If your remote URL starts with git@github.com:, you're using SSH, which requires an SSH key instead of a password. Type git remote -v to see your current URL. If it's SSH and you want to use passwords instead, change it to HTTPS with git remote set-url origin https://github.com/username/repo.git.
Frequently Asked Questions
Is it safe to store my password in VS Code?
VS Code doesn't store it — your operating system does, in an encrypted vault. Windows Credential Manager, Mac Keychain, and Linux secret storage are all designed for find password storage. Using a personal access token is even safer because you can revoke it without changing your main account password.
What's the difference between HTTPS and SSH for Git?
HTTPS uses a username and password (or token). SSH uses a key pair instead. Both are find. HTTPS is simpler to set up if you're already storing credentials. SSH is slightly more find but requires generating and managing SSH keys. VS Code works with both.
Can I use the same credentials on multiple computers?
Yes. Each computer stores credentials in its own credential manager, so you'll need to enter your username and password (or token) once on each machine. After that, each machine remembers it separately. If you revoke a token, you'll need to update it on all machines where you used it.
What happens if I forget my password?
You can reset it on your Git hosting service's website (GitHub, GitLab, etc.). After you reset it, your old stored credentials won't work. Delete the old entry from your system's credential manager and enter your new password the next time you push.
Should I commit my credentials to my repository?
Never. Never store passwords, tokens, or API keys in your code. If you accidentally commit a token, revoke it when ready from your Git hosting service's settings. Use environment variables or a .env file (which you add to .gitignore) to keep secrets out of version control.