Repository navigation
Clear Git helper credentials on logout - #15152
Merged
BagToad merged 1 commit intoNov 24, 2026
Merged
Conversation
Reject cached HTTPS credentials for the selected host after local logout. Keep logout successful and print a warning when Git credential cleanup fails. Reuse the existing credential updater. Co-authored-by: Babak K. Shandiz <[email protected]>
BagToad
requested review from
tidy-dev
and
a balanced review from Copilot
and removed request for
a team
November 24, 2026 21:42
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the logout credential-cleanup change.
No open issues 🎉
What changed in this PR
This PR extends gh auth logout to remove saved HTTPS credentials from Git credential helpers, addressing the retained credentials reported in #13111 while preserving the parent PR’s OAuth revocation behavior.
Changes:
- Reuses the shared credential updater after successful local logout, including with
--no-revoke. - Documents host-wide cleanup and warns on stderr if cleanup fails without failing logout.
- Adds tests for Git client wiring, host selection, cleanup ordering, and failure warnings.
| File | Description |
|---|---|
pkg/cmd/auth/logout/logout.go |
Wires the Git client, performs helper cleanup, and documents warning behavior. |
pkg/cmd/auth/logout/logout_test.go |
Adds credential-rejection stubs and checks cleanup behavior in interactive and non-interactive flows. |
Review effort: Balanced
babakks
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #13111. Builds on #15100 and carries the Git helper cleanup from @babakks's #13450.
Description
gh auth logoutnow clears saved HTTPS credentials for the selected host from Git credential helpers.Login can store credentials in an external helper with
git credential approve. Logout currently leaves that copy behind. This change callsgit credential rejectafter local logout, using the existing shared updater.Cleanup failures print a warning without failing logout. The parent PR's OAuth revocation, refresh-and-retry behavior, locking, and account selection are unchanged.
How did you test this change?
I ran the same command before and after this layer:
gh auth logout --hostname github.com --user monalisaI used synthetic API responses, two accounts, an in-memory keyring, and a test-owned Git
storehelper. Both builds returned exit 0 and kept the other account signed in. Before, the helper retained the credential. After, it removed the credential forgithub.comand kept the control host's credential.I also ran the changed build without Git on
PATH. It printed the cleanup warning, returned exit 0, and still removed the selected local account.The recording includes preparation, the real
ghcommand and its output, and state checks for each case. No live authentication or OS keychain was used. Nativeosxkeychainandwincredbehavior was not exercised.git-helper-logout-cleanup.mp4
Open chapters and notes
Key points
--no-revoke.Notes for reviewers
Start with the
logoutflow. It reusesRejectExisting, so no new Git credential protocol handling is needed.#13111 reports the retained helper credential. #13450 contains the original cleanup change. #15100 supplies the OAuth behavior below this layer.
Local validation
I used Go 1.27.4 and the repository-pinned golangci-lint v2.15.0 with isolated configuration.
Authorship and follow-up
Who wrote this:
Who answers review comments: