git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[BUG] git credential url field ordering/documentation issue

From
MMMuhammad Fahri Muharram <mfahrim7@gmail.com>
Date
Aug 11, 2025, 11:19 UTC
Message-ID
<CACEVnOLzZkR_oELBFg2Wfu83cos8VRCNprx3Vad_wtDncFPQtw@mail.gmail.com>

In git credential source code, whenever an url field is encountered it will call credential_from_url_1 which will then call credential_clear on the credential struct. https://github.com/git/git/blob/master/credential.c#L625

This means the credential struct is cleared whenever a url= line is processed, but the documentation does not mention that the url field must be placed before other fields to avoid wiping them.

This causes confusing behaviour:

$ printf "host=github.com\nusername=A\nprotocol=https" | git credential approve $ printf "username=A\nurl=https://github.com" | git credential fill Password for 'https://SeeStarz@github.com': protocol=https host=github.com username=SeeStarz password= $ printf "url=https://github.com\nusername=A" | git credential fill protocol=https host=github.com username=A password=B

On the second command, due to username being wiped, git credential fill defaults to using ~/.gitconfig which in my case uses the username SeeStarz. The expected behaviour is that both invocations of git credential fill show username=A and password=B. Please consider clarifying this behavior in the documentation or adjusting the implementation to avoid this surprising side effect.

Thank you.
Message 1 of 1 in “[BUG] git credential url field ordering/documentation issue”
  1. Muhammad Fahri MuharramAug 11, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.