How to save and delete Git credentials (username and password) on Linux

I always forget how to save and delete Git credentials (username and password) on Linux, so here's a memo for myself.
How to save Git credentials
You can save Git credentials with the following command. Please note that the credentials will be saved in plain text in ~/.git-credentials.
git config --global credential.helper storeHow to delete saved Git credentials
The credentials saved using the aforementioned command can be disabled with the following command.
git config --global --unset credential.helperThis command unsets the credential storage method (meaning it stops using saved credentials), so it doesn't strictly delete the credentials.
To completely delete credentials, you need to either delete the ~/.git-credentials file entirely or open it with a text editor and individually delete the entries.
The git credential reject command can be used to delete credentials that match certain conditions. For example, you can delete only GitHub credentials by running a command like this:
printf "protocol=https\nhost=github.com\n\n" | git credential rejectHowever, this command is long and hard to remember, so I think it's easier to just edit the `~/.git-credentials` file.
References
Share this article
Follow us for updates
Adding us to your preferred sources on Google makes it easier to find our articles on Google. Also, be sure to follow us on X and our RSS feed.
Next articles
- How to restore VS Code’s previous UI design
- GitHub to use Copilot data for AI training from April 24; how to opt out?
- How to configure GitHub Copilot not to train on your code
- How to install Bun on Windows
- [Android] Can you no longer hide images on X? How to reduce image data usage with the new settings
-1.png&w=1080&q=75)
I've been using JavaScript more than my native language since birth. I am nowhere and everywhere on the internet.
I build web apps and browser extensions in TypeScript as a web frontend programmer. I released Shadowban Scanner, a tool that detects shadowbans on X, and Restore Link Card, a tool that brings back link cards. Media outlets in Japan and abroad covered both tools. For iGEM 2023, I built the Wiki for Team Japan-United and helped the team win the Grand Prize. On my blog, I cover news about X and social media, test and troubleshoot bugs, and share frontend development insights.


![Screenshot of the VS Code settings screen with [Workbench > Experimental: Modern UI] highlighted by a red border](/_next/image/?url=%2Fapi%2Fmedia%2Ffile%2Fvs-code-experimental-modern-ui-setting.png&w=3840&q=75)






![Xのブックマーク画面に複数のフォルダーが表示されている画像。フォルダーの名前はそれぞれ[すべてのブックマーク][イラスト][面白い投稿]となっている](/_next/image/?url=%2Fapi%2Fmedia%2Ffile%2Fimage-1378.png&w=1920&q=75)



