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.
-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.




![スマートフォンのホーム画面の[Social]フォルダーを表示した写真。フォルダー内にはFacebook、Instagram、Threads、X、LinkedIn、TikTok、YouTubeのアイコンが配置されている](/_next/image/?url=%2Fapi%2Fmedia%2Ffile%2Ffacebook-instagram-threads-x-twitter-linkedin-tiktok-youtube-mobile-app-unsplash.jpg&w=3840&q=75)









