Roboin Blog

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

画面に緑色の南京錠やボールが配置されているCG画像

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.

Advertisement
Terminal window
git config --global credential.helper store

How to delete saved Git credentials

The credentials saved using the aforementioned command can be disabled with the following command.

Terminal window
git config --global --unset credential.helper

This 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:

Terminal window
printf "protocol=https\nhost=github.com\n\n" | git credential reject

However, this command is long and hard to remember, so I think it's easier to just edit the `~/.git-credentials` file.

Advertisement

References

Share this article

Share on XShare on BlueskyShare on MisskeyShare on LINEShare on Threads

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.

Add as a preferred source on GoogleAdd as a preferred source on GoogleX Logo
Advertisement
著者のアイコン画像

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.