In the question Why am I suddenly not having push permission? I was advised to use this command to store my credential:
printf "host=github.com\nprotocol=https\nusername=ooker777\npassword=ghp_yourToken" | git credential-manager-core store
I was explained that the command doesn't accept arguments, so it must be piped like that. Why is it so? Why not something like this?
git credential-manager-core store password myToken
The internal interface for storing and retrieving credentials from system-specific helpers described by "git credential
" refers to credential.h
.
The design presented in that file confirms the use of pipes to get arguments:
+-----------------------+
| Git code (C) |--- to server requiring --->
| | authentication
|.......................|
| C credential API |--- prompt ---> User
+-----------------------+
^ |
| pipe |
| v
+-----------------------+
| Git credential helper |
+-----------------------+
The Git code (typically a remote-helper) will call the C API to obtain credential data like a login/password pair (
credential_fill
).
The API will itself call a remote helper (e.g. "git credential-cache
" or "git credential-store
") that may retrieve credential data from a store.
If the credential helper cannot find the information, the C API will prompt the user. Then, the caller of the API takes care of contacting the server, and does the actual authentication.