---
title: How to save and delete Git credentials (username and password) on Linux
url: https://roboin.io/article/en/2026/02/25/how-to-save-and-remove-git-credentials-username-password-on-linux/
description: I always forget how to save and delete Git credentials (username
  and password) on Linux, so here's a memo for myself.
publishedDate: 2026-02-24T16:58:57.023Z
modifiedDate: 2026-02-24T16:58:57.023Z
thumbnail: https://roboin.io/api/media/file/unsplash-lock.jpg
thumbnailAlt: 画面に緑色の南京錠やボールが配置されているCG画像
thumbnailCaption: N/A
---

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

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

```bash
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:

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

## References

- [Gitのパスワードを保存する方法 - Qiita](https://qiita.com/is_mgmt_dept/items/81dc4558c0478e533e03)
- [linux - How to remove cached credentials from Git? - Stack Overflow](https://stackoverflow.com/questions/44246876/how-to-remove-cached-credentials-from-git)
- [Git - git-credential Documentation](https://git-scm.com/docs/git-credential)