Programming

Where Git Stores Codeberg Credentials & Token

Discover where Git stores credentials and Codeberg access tokens after HTTPS auth. Learn git credential helper locations like ~/.git-credentials, Windows Credential Manager, macOS Keychain for secure management.

1 answer 1 view

Git stores the credentials that you entered for a remote in the credential helper that Git is configured to use, not in the repository’s .git/config file.
The helper keeps the username and the access‑token (or password) in a location that depends on your operating system and on the helper that is configured.

OS / Helper Typical storage location How to find it
Linux (default cache helper) In memory for a limited time (default 15 min) git config --global credential.helper shows cache
Linux (if you set store helper) ~/.git-credentials (plain‑text file) git config --global credential.helper shows store
macOS (osxkeychain helper) macOS Keychain git config --global credential.helper shows osxkeychain
Windows (wincred / manager helper) Windows Credential Manager git config --global credential.helper shows wincred or manager

How to check which helper you’re using

bash
git config --global credential.helper

If nothing is returned, Git will fall back to the system‑wide configuration (~/.gitconfig or /etc/gitconfig) or to the default helper for your OS.

Where the credentials live

  • store helper – plain‑text file ~/.git-credentials. Each line looks like:
https://username:token@codeberg.org
  • cache helper – stored in RAM only; you won’t find a file on disk.

  • osxkeychain helper – stored in the macOS Keychain under the “Internet Password” category.

  • wincred / manager helper – stored in the Windows Credential Manager under “Generic Credentials” or “Windows Credentials”.

Quick sanity check

bash
# List all stored credentials (Linux store helper)
cat ~/.git-credentials

or

bash
# macOS Keychain
security find-internet-password -s codeberg.org

or

powershell
# Windows Credential Manager (PowerShell)
Get-Credential -UserName "codeberg.org" -Message "Check stored credentials"

Once you know which helper is in use, you can view, edit, or delete the stored credentials from the appropriate location.

Git credentials for your Codeberg repository, including the access token you entered during HTTPS authentication, get stored by Git’s credential helper—not in the repo’s .git/config or remote URL. Run git config --global credential.helper to see which one it’s using; common spots include ~/.git-credentials for the plain-text “store” helper or secure OS vaults like Windows Credential Manager. This setup lets you push without re-entering creds every time, but knowing the exact location helps if you need to update or revoke them.


Contents


How Git Handles Credentials

Ever cloned a Codeberg repo, punched in your username and access token once, and suddenly pushes just work? That’s Git’s credential helper in action. It intercepts authentication requests during HTTPS operations (like git push to https://codeberg.org/your/repo.git) and stashes your creds securely—or not so securely, depending on the config.

By default, Git doesn’t hardcode anything in .git/config or the remote URL (which stays clean like origin https://codeberg.org/user/repo.git). Instead, it delegates to a helper system. The official Git documentation lists options like store, cache, osxkeychain, or manager. No helper? It falls back to OS defaults or prompts every time.

Quick check: fire up your terminal and type

bash
git config --global credential.helper

Nothing? Check system-wide with --system or repo-local --local. On fresh installs, Linux might default to cache (RAM-only), macOS to osxkeychain, Windows to manager-core.

And here’s the kicker—helpers evolved because plain passwords sucked for GitHub/Codeberg-style tokens. Codeberg docs confirm: use your personal access token as the “password” field. Git treats it identically.


Git Credentials Storage Locations

Once authenticated, where does Git actually stash that username:token combo? It hinges on the helper. The most straightforward is store, which dumps everything into a plain-text file at ~/.git-credentials (or $XDG_CONFIG_HOME/git/credentials if set).

Each line follows this format:

https://yourusername:ghp_youraccesstoken@codeberg.org

No quotes, no extras—just URL-encoded creds. Permissions tighten to 0600 automatically, but it’s still readable by you (or malware).

Other helpers hide it better:

Helper Storage Type Persistence Example Output from git config credential.helper
store File: ~/.git-credentials Permanent store
cache RAM (default 900s/15min) Temporary cache
osxkeychain macOS Keychain Permanent osxkeychain
manager-core / wincred Windows Credential Manager Permanent manager-core

From the Git Book on credential storage, store is explicit but risky—great for scripts, lousy for shared machines. cache vanishes on reboot or git credential-cache exit.

Pro tip: If you spot store in your config, that’s likely your Codeberg token’s home. cat ~/.git-credentials reveals it instantly (mask those chars!).


Platform-Specific Storage Details

Git credential storage morphs by OS. No one-size-fits-all path, which trips folks up. Let’s break it down.

Linux (Ubuntu, Fedora, etc.)
Defaults to cache—creds evaporate fast. Set store? Boom, ~/.git-credentials. For encrypted bliss, install libsecret via sudo apt install libsecret-1-0 libsecret-1-dev then git config --global credential.helper /usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret. Stores in GNOME Keyring or KDE Wallet.

macOS
osxkeychain rules. Creds land in Keychain Access app under “Passwords” > search “codeberg.org”. Peek with:

bash
security find-internet-password -s codeberg.org -w

(Adds -w for plaintext—careful!)

Windows
manager-core (Git Credential Manager) or legacy wincred. Hunt in Credential Manager: Windows Search > “Credential Manager” > Web Credentials or Windows Credentials > “git:https://codeberg.org”. PowerShell probe:

powershell
cmdkey /list | findstr codeberg

Exact file? GCM uses %USERPROFILE%.gcm\dpapi_store or similar encrypted blobs—not human-readable.

Cross-platform table for sanity:

OS Default Helper View Command/Tool
Linux cache cat ~/.git-credentials (if store)
macOS osxkeychain Keychain Access app
Windows manager-core Credential Manager GUI

Git Credential Manager docs confirm Windows paths vary by version—Win10+ favors GCM.


Verifying Codeberg Access Tokens

Codeberg plays nice with standard Git—no custom storage. Your token (generated at docs.codeberg.org/security/2fa) acts as password. Pushed successfully once? It’s cached.

To verify:

  1. git config --global credential.helper → note the helper.
  2. For store: cat ~/.git-credentials | grep codeberg (expect https://user:token@codeberg.org).
  3. macOS: Keychain Access > “codeberg.org” > show password.
  4. Windows: Credential Manager > edit/delete entry.
  5. Test push: git push origin main—no prompt means it’s there.

Erase? Helpers have protocols:

bash
echo "https://codeberg.org" | git credential reject

Then git credential-cache exit for cache. Codeberg-specific: revoke token in web UI if compromised.

Stack Overflow threads like this one on GitHub tokens mirror Codeberg—same Git mechanics.


Security Best Practices

Plain-text ~/.git-credentials? Convenient, but a hacker’s dream. Git warns explicitly: anyone with file access reads your token.

Switch smarter:

  • SSH keys: ssh-keygen, add public key to Codeberg, switch remote: git remote set-url origin git@codeberg.org:user/repo.git. No tokens, ever.
  • Encrypted helpers: Linux libsecret, pass gnome-keyring-daemon.
  • GCM on all platforms: git config --global credential.helper manager-core.
  • Rotate tokens yearly; scope minimally (e.g., repo write).

Forgejo issue 2809 on Codeberg echoes: ditch store, embrace SSH or keyrings. Your laptop’s safe? Maybe. Shared server? Nope.


Troubleshooting Credential Issues

Prompts keep popping? Helper misconfigured. git config --global --unset credential.helper resets. Still stuck?

  • Cache expired: git credential-cache exit.
  • Wrong token: Revoke in Codeberg, re-enter on next push.
  • No file found: Helper isn’t store. Force it: git config --global credential.helper store.
  • Windows woes: Restart Credential Manager service or cmdkey /delete:git:https://codeberg.org.
  • Permissions: chmod 600 ~/.git-credentials.

Medium guides like this credential helper overview nail common paths. Reddit Ubuntu tips push libsecret for sanity.

Debug mode: GIT_CURL_VERBOSE=1 git push shows auth flow.


Sources

  1. Git Credential Store — Details on store helper and ~/.git-credentials file format: https://git-scm.com/docs/git-credential-store
  2. Git Book: Credential Storage — Overview of helpers like cache, store, osxkeychain, manager: https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
  3. Git Credentials Documentation — List of credential helpers and protocols: https://git-scm.com/docs/gitcredentials
  4. Antora Git Credentials Path — Confirmation of ~/.git-credentials and URL format: https://docs.antora.org/antora/latest/playbook/git-credentials-path-and-contents/
  5. Codeberg Access Tokens — How to generate and use tokens with Git HTTPS: https://docs.codeberg.org/advanced/access-token/
  6. GitHub Token Storage on Windows — Windows Credential Manager for HTTPS creds (applies to Codeberg): https://stackoverflow.com/questions/58263306/where-is-github-authentication-token-stored-on-windows
  7. Git Credential Manager Stores — GCM storage paths like .gcm/dpapi_store: https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/credstores.md
  8. Storing Git Credentials Helper — Cross-platform paths for Windows, macOS, Linux: https://techexpertise.medium.com/storing-git-credentials-with-git-credential-helper-33d22a6b5ce7
  9. Forgejo Credential Warnings — Advice against store helper, prefer SSH/libsecret: https://codeberg.org/forgejo/forgejo/issues/2809

Conclusion

Git credentials storage boils down to your credential helper—check it first with git config --global credential.helper, then hunt ~/.git-credentials (store), Keychain (macOS), or Credential Manager (Windows). For Codeberg access tokens, it’s all standard Git fare, but prioritize SSH or encrypted helpers over plain files to keep things locked down. Run that config command today; you’ll sleep better knowing exactly where your token lives.

Authors
Verified by moderation
Where Git Stores Codeberg Credentials & Token