| 1 |
<!DOCTYPE html> |
| 2 |
|
| 3 |
<html> |
| 4 |
|
| 5 |
<head> |
| 6 |
|
| 7 |
<meta charset="utf-8" /> |
| 8 |
<meta name="generator" content="pandoc" /> |
| 9 |
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" /> |
| 10 |
|
| 11 |
<meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
<title>git credential helpers</title> |
| 16 |
|
| 17 |
<script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to |
| 18 |
// be compatible with the behavior of Pandoc < 2.8). |
| 19 |
document.addEventListener('DOMContentLoaded', function(e) { |
| 20 |
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); |
| 21 |
var i, h, a; |
| 22 |
for (i = 0; i < hs.length; i++) { |
| 23 |
h = hs[i]; |
| 24 |
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 |
| 25 |
a = h.attributes; |
| 26 |
while (a.length > 0) h.removeAttribute(a[0].name); |
| 27 |
} |
| 28 |
}); |
| 29 |
</script> |
| 30 |
|
| 31 |
<style type="text/css"> |
| 32 |
code{white-space: pre-wrap;} |
| 33 |
span.smallcaps{font-variant: small-caps;} |
| 34 |
span.underline{text-decoration: underline;} |
| 35 |
div.column{display: inline-block; vertical-align: top; width: 50%;} |
| 36 |
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;} |
| 37 |
ul.task-list{list-style: none;} |
| 38 |
</style> |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
<style type="text/css"> |
| 43 |
code { |
| 44 |
white-space: pre; |
| 45 |
} |
| 46 |
.sourceCode { |
| 47 |
overflow: visible; |
| 48 |
} |
| 49 |
</style> |
| 50 |
<style type="text/css" data-origin="pandoc"> |
| 51 |
pre > code.sourceCode { white-space: pre; position: relative; } |
| 52 |
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; } |
| 53 |
pre > code.sourceCode > span:empty { height: 1.2em; } |
| 54 |
.sourceCode { overflow: visible; } |
| 55 |
code.sourceCode > span { color: inherit; text-decoration: inherit; } |
| 56 |
div.sourceCode { margin: 1em 0; } |
| 57 |
pre.sourceCode { margin: 0; } |
| 58 |
@media screen { |
| 59 |
div.sourceCode { overflow: auto; } |
| 60 |
} |
| 61 |
@media print { |
| 62 |
pre > code.sourceCode { white-space: pre-wrap; } |
| 63 |
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; } |
| 64 |
} |
| 65 |
pre.numberSource code |
| 66 |
{ counter-reset: source-line 0; } |
| 67 |
pre.numberSource code > span |
| 68 |
{ position: relative; left: -4em; counter-increment: source-line; } |
| 69 |
pre.numberSource code > span > a:first-child::before |
| 70 |
{ content: counter(source-line); |
| 71 |
position: relative; left: -1em; text-align: right; vertical-align: baseline; |
| 72 |
border: none; display: inline-block; |
| 73 |
-webkit-touch-callout: none; -webkit-user-select: none; |
| 74 |
-khtml-user-select: none; -moz-user-select: none; |
| 75 |
-ms-user-select: none; user-select: none; |
| 76 |
padding: 0 4px; width: 4em; |
| 77 |
color: #aaaaaa; |
| 78 |
} |
| 79 |
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } |
| 80 |
div.sourceCode |
| 81 |
{ } |
| 82 |
@media screen { |
| 83 |
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; } |
| 84 |
} |
| 85 |
code span.al { color: #ff0000; font-weight: bold; } /* Alert */ |
| 86 |
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ |
| 87 |
code span.at { color: #7d9029; } /* Attribute */ |
| 88 |
code span.bn { color: #40a070; } /* BaseN */ |
| 89 |
code span.bu { } /* BuiltIn */ |
| 90 |
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ |
| 91 |
code span.ch { color: #4070a0; } /* Char */ |
| 92 |
code span.cn { color: #880000; } /* Constant */ |
| 93 |
code span.co { color: #60a0b0; font-style: italic; } /* Comment */ |
| 94 |
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ |
| 95 |
code span.do { color: #ba2121; font-style: italic; } /* Documentation */ |
| 96 |
code span.dt { color: #902000; } /* DataType */ |
| 97 |
code span.dv { color: #40a070; } /* DecVal */ |
| 98 |
code span.er { color: #ff0000; font-weight: bold; } /* Error */ |
| 99 |
code span.ex { } /* Extension */ |
| 100 |
code span.fl { color: #40a070; } /* Float */ |
| 101 |
code span.fu { color: #06287e; } /* Function */ |
| 102 |
code span.im { } /* Import */ |
| 103 |
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ |
| 104 |
code span.kw { color: #007020; font-weight: bold; } /* Keyword */ |
| 105 |
code span.op { color: #666666; } /* Operator */ |
| 106 |
code span.ot { color: #007020; } /* Other */ |
| 107 |
code span.pp { color: #bc7a00; } /* Preprocessor */ |
| 108 |
code span.sc { color: #4070a0; } /* SpecialChar */ |
| 109 |
code span.ss { color: #bb6688; } /* SpecialString */ |
| 110 |
code span.st { color: #4070a0; } /* String */ |
| 111 |
code span.va { color: #19177c; } /* Variable */ |
| 112 |
code span.vs { color: #4070a0; } /* VerbatimString */ |
| 113 |
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ |
| 114 |
|
| 115 |
</style> |
| 116 |
<script> |
| 117 |
// apply pandoc div.sourceCode style to pre.sourceCode instead |
| 118 |
(function() { |
| 119 |
var sheets = document.styleSheets; |
| 120 |
for (var i = 0; i < sheets.length; i++) { |
| 121 |
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue; |
| 122 |
try { var rules = sheets[i].cssRules; } catch (e) { continue; } |
| 123 |
var j = 0; |
| 124 |
while (j < rules.length) { |
| 125 |
var rule = rules[j]; |
| 126 |
// check if there is a div.sourceCode rule |
| 127 |
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") { |
| 128 |
j++; |
| 129 |
continue; |
| 130 |
} |
| 131 |
var style = rule.style.cssText; |
| 132 |
// check if color or background-color is set |
| 133 |
if (rule.style.color === '' && rule.style.backgroundColor === '') { |
| 134 |
j++; |
| 135 |
continue; |
| 136 |
} |
| 137 |
// replace div.sourceCode by a pre.sourceCode rule |
| 138 |
sheets[i].deleteRule(j); |
| 139 |
sheets[i].insertRule('pre.sourceCode{' + style + '}', j); |
| 140 |
} |
| 141 |
} |
| 142 |
})(); |
| 143 |
</script> |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
<style type="text/css">body { |
| 149 |
background-color: #fff; |
| 150 |
margin: 1em auto; |
| 151 |
max-width: 700px; |
| 152 |
overflow: visible; |
| 153 |
padding-left: 2em; |
| 154 |
padding-right: 2em; |
| 155 |
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; |
| 156 |
font-size: 14px; |
| 157 |
line-height: 1.35; |
| 158 |
} |
| 159 |
#TOC { |
| 160 |
clear: both; |
| 161 |
margin: 0 0 10px 10px; |
| 162 |
padding: 4px; |
| 163 |
width: 400px; |
| 164 |
border: 1px solid #CCCCCC; |
| 165 |
border-radius: 5px; |
| 166 |
background-color: #f6f6f6; |
| 167 |
font-size: 13px; |
| 168 |
line-height: 1.3; |
| 169 |
} |
| 170 |
#TOC .toctitle { |
| 171 |
font-weight: bold; |
| 172 |
font-size: 15px; |
| 173 |
margin-left: 5px; |
| 174 |
} |
| 175 |
#TOC ul { |
| 176 |
padding-left: 40px; |
| 177 |
margin-left: -1.5em; |
| 178 |
margin-top: 5px; |
| 179 |
margin-bottom: 5px; |
| 180 |
} |
| 181 |
#TOC ul ul { |
| 182 |
margin-left: -2em; |
| 183 |
} |
| 184 |
#TOC li { |
| 185 |
line-height: 16px; |
| 186 |
} |
| 187 |
table { |
| 188 |
margin: 1em auto; |
| 189 |
border-width: 1px; |
| 190 |
border-color: #DDDDDD; |
| 191 |
border-style: outset; |
| 192 |
border-collapse: collapse; |
| 193 |
} |
| 194 |
table th { |
| 195 |
border-width: 2px; |
| 196 |
padding: 5px; |
| 197 |
border-style: inset; |
| 198 |
} |
| 199 |
table td { |
| 200 |
border-width: 1px; |
| 201 |
border-style: inset; |
| 202 |
line-height: 18px; |
| 203 |
padding: 5px 5px; |
| 204 |
} |
| 205 |
table, table th, table td { |
| 206 |
border-left-style: none; |
| 207 |
border-right-style: none; |
| 208 |
} |
| 209 |
table thead, table tr.even { |
| 210 |
background-color: #f7f7f7; |
| 211 |
} |
| 212 |
p { |
| 213 |
margin: 0.5em 0; |
| 214 |
} |
| 215 |
blockquote { |
| 216 |
background-color: #f6f6f6; |
| 217 |
padding: 0.25em 0.75em; |
| 218 |
} |
| 219 |
hr { |
| 220 |
border-style: solid; |
| 221 |
border: none; |
| 222 |
border-top: 1px solid #777; |
| 223 |
margin: 28px 0; |
| 224 |
} |
| 225 |
dl { |
| 226 |
margin-left: 0; |
| 227 |
} |
| 228 |
dl dd { |
| 229 |
margin-bottom: 13px; |
| 230 |
margin-left: 13px; |
| 231 |
} |
| 232 |
dl dt { |
| 233 |
font-weight: bold; |
| 234 |
} |
| 235 |
ul { |
| 236 |
margin-top: 0; |
| 237 |
} |
| 238 |
ul li { |
| 239 |
list-style: circle outside; |
| 240 |
} |
| 241 |
ul ul { |
| 242 |
margin-bottom: 0; |
| 243 |
} |
| 244 |
pre, code { |
| 245 |
background-color: #f7f7f7; |
| 246 |
border-radius: 3px; |
| 247 |
color: #333; |
| 248 |
white-space: pre-wrap; |
| 249 |
} |
| 250 |
pre { |
| 251 |
border-radius: 3px; |
| 252 |
margin: 5px 0px 10px 0px; |
| 253 |
padding: 10px; |
| 254 |
} |
| 255 |
pre:not([class]) { |
| 256 |
background-color: #f7f7f7; |
| 257 |
} |
| 258 |
code { |
| 259 |
font-family: Consolas, Monaco, 'Courier New', monospace; |
| 260 |
font-size: 85%; |
| 261 |
} |
| 262 |
p > code, li > code { |
| 263 |
padding: 2px 0px; |
| 264 |
} |
| 265 |
div.figure { |
| 266 |
text-align: center; |
| 267 |
} |
| 268 |
img { |
| 269 |
background-color: #FFFFFF; |
| 270 |
padding: 2px; |
| 271 |
border: 1px solid #DDDDDD; |
| 272 |
border-radius: 3px; |
| 273 |
border: 1px solid #CCCCCC; |
| 274 |
margin: 0 5px; |
| 275 |
} |
| 276 |
h1 { |
| 277 |
margin-top: 0; |
| 278 |
font-size: 35px; |
| 279 |
line-height: 40px; |
| 280 |
} |
| 281 |
h2 { |
| 282 |
border-bottom: 4px solid #f7f7f7; |
| 283 |
padding-top: 10px; |
| 284 |
padding-bottom: 2px; |
| 285 |
font-size: 145%; |
| 286 |
} |
| 287 |
h3 { |
| 288 |
border-bottom: 2px solid #f7f7f7; |
| 289 |
padding-top: 10px; |
| 290 |
font-size: 120%; |
| 291 |
} |
| 292 |
h4 { |
| 293 |
border-bottom: 1px solid #f7f7f7; |
| 294 |
margin-left: 8px; |
| 295 |
font-size: 105%; |
| 296 |
} |
| 297 |
h5, h6 { |
| 298 |
border-bottom: 1px solid #ccc; |
| 299 |
font-size: 105%; |
| 300 |
} |
| 301 |
a { |
| 302 |
color: #0033dd; |
| 303 |
text-decoration: none; |
| 304 |
} |
| 305 |
a:hover { |
| 306 |
color: #6666ff; } |
| 307 |
a:visited { |
| 308 |
color: #800080; } |
| 309 |
a:visited:hover { |
| 310 |
color: #BB00BB; } |
| 311 |
a[href^="http:"] { |
| 312 |
text-decoration: underline; } |
| 313 |
a[href^="https:"] { |
| 314 |
text-decoration: underline; } |
| 315 |
|
| 316 |
code > span.kw { color: #555; font-weight: bold; } |
| 317 |
code > span.dt { color: #902000; } |
| 318 |
code > span.dv { color: #40a070; } |
| 319 |
code > span.bn { color: #d14; } |
| 320 |
code > span.fl { color: #d14; } |
| 321 |
code > span.ch { color: #d14; } |
| 322 |
code > span.st { color: #d14; } |
| 323 |
code > span.co { color: #888888; font-style: italic; } |
| 324 |
code > span.ot { color: #007020; } |
| 325 |
code > span.al { color: #ff0000; font-weight: bold; } |
| 326 |
code > span.fu { color: #900; font-weight: bold; } |
| 327 |
code > span.er { color: #a61717; background-color: #e3d2d2; } |
| 328 |
</style> |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
</head> |
| 334 |
|
| 335 |
<body> |
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
<h1 class="title toc-ignore">git credential helpers</h1> |
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
<div id="general-remarks" class="section level1"> |
| 345 |
<h1>General remarks</h1> |
| 346 |
<ul> |
| 347 |
<li><p>For <code>git credential approve</code> git (2.28.0 macOS) does |
| 348 |
not even call the credential helper if no username is supplied:</p> |
| 349 |
<div class="sourceCode" id="cb1"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> export GIT_TRACE=true</span> |
| 350 |
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> password=secret<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential approve</span> |
| 351 |
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="ex">10:43:36.712290</span> git.c:444 trace: built-in: git credential approve</span> |
| 352 |
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span></span></code></pre></div></li> |
| 353 |
<li><p>The <code>credential.helper</code> key has a multi-set value, so |
| 354 |
if you add a new value, the old values are still kept. From git 2.9 |
| 355 |
specifying an empty string removes the previously defined |
| 356 |
helpers.</p></li> |
| 357 |
</ul> |
| 358 |
</div> |
| 359 |
<div id="credential-helper-survey" class="section level1"> |
| 360 |
<h1>Credential helper survey</h1> |
| 361 |
<p>We do this with an eye of supporting usernames and multiple |
| 362 |
users.</p> |
| 363 |
<div id="cache" class="section level2"> |
| 364 |
<h2><code>cache</code></h2> |
| 365 |
<ul> |
| 366 |
<li><p>Docs: <a href="https://git-scm.com/docs/git-credential-cache" class="uri">https://git-scm.com/docs/git-credential-cache</a></p></li> |
| 367 |
<li><p>This helper is not included in the default git installer on |
| 368 |
Windows . :(</p></li> |
| 369 |
<li><p>This is how we can set up <code>cache</code> for a particular |
| 370 |
repository:</p> |
| 371 |
<pre><code>❯ mkdir foo |
| 372 |
❯ cd foo |
| 373 |
❯ git init . |
| 374 |
11:43:28.618841 git.c:444 trace: built-in: git init . |
| 375 |
Initialized empty Git repository in /private/tmp/foo/.git/ |
| 376 |
|
| 377 |
❯ git config --add credential.helper "" |
| 378 |
11:43:50.682962 git.c:444 trace: built-in: git config --add credential.helper '' |
| 379 |
|
| 380 |
❯ git config --add credential.helper cache |
| 381 |
11:43:54.577707 git.c:444 trace: built-in: git config --add credential.helper cache |
| 382 |
|
| 383 |
❯ cat .git/config |
| 384 |
[core] |
| 385 |
repositoryformatversion = 0 |
| 386 |
filemode = true |
| 387 |
bare = false |
| 388 |
logallrefupdates = true |
| 389 |
ignorecase = true |
| 390 |
precomposeunicode = true |
| 391 |
[credential] |
| 392 |
helper = |
| 393 |
helper = cache</code></pre></li> |
| 394 |
<li><p>Now let’s add credentials:</p> |
| 395 |
<pre><code>❯ (echo url=https://github.com; echo username=token; echo password=secret; echo ) | git credential approve |
| 396 |
11:45:16.813913 git.c:444 trace: built-in: git credential approve |
| 397 |
11:45:16.814431 run-command.c:663 trace: run_command: 'git credential-cache store' |
| 398 |
11:45:16.823008 git.c:704 trace: exec: git-credential-cache store |
| 399 |
11:45:16.823637 run-command.c:663 trace: run_command: git-credential-cache store |
| 400 |
11:45:16.842902 run-command.c:663 trace: run_command: git-credential-cache--daemon /Users/gaborcsardi/.cache/git/credential/socket |
| 401 |
|
| 402 |
❯ (echo url=https://github.com; echo username=token2; echo password=secret2; echo ) | git credential approve |
| 403 |
11:45:28.927712 git.c:444 trace: built-in: git credential approve |
| 404 |
11:45:28.928108 run-command.c:663 trace: run_command: 'git credential-cache store' |
| 405 |
11:45:28.937087 git.c:704 trace: exec: git-credential-cache store |
| 406 |
11:45:28.937695 run-command.c:663 trace: run_command: git-credential-cache store</code></pre></li> |
| 407 |
<li><p>Query with username works correctly:</p> |
| 408 |
<pre><code>❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 409 |
11:46:40.689122 git.c:444 trace: built-in: git credential fill |
| 410 |
11:46:40.689638 run-command.c:663 trace: run_command: 'git credential-cache get' |
| 411 |
11:46:40.696784 git.c:704 trace: exec: git-credential-cache get |
| 412 |
11:46:40.697333 run-command.c:663 trace: run_command: git-credential-cache get |
| 413 |
protocol=https |
| 414 |
host=github.com |
| 415 |
username=token |
| 416 |
password=secret |
| 417 |
|
| 418 |
❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 419 |
11:46:43.767002 git.c:444 trace: built-in: git credential fill |
| 420 |
11:46:43.767676 run-command.c:663 trace: run_command: 'git credential-cache get' |
| 421 |
11:46:43.778637 git.c:704 trace: exec: git-credential-cache get |
| 422 |
11:46:43.779201 run-command.c:663 trace: run_command: git-credential-cache get |
| 423 |
protocol=https |
| 424 |
host=github.com |
| 425 |
username=token2 |
| 426 |
password=secret2</code></pre></li> |
| 427 |
<li><p>Query without username works, and returns <em>some</em> |
| 428 |
credential:</p> |
| 429 |
<pre><code>❯ (echo url=https://github.com; echo ) | git credential fill |
| 430 |
11:45:58.200272 git.c:444 trace: built-in: git credential fill |
| 431 |
11:45:58.200667 run-command.c:663 trace: run_command: 'git credential-cache get' |
| 432 |
11:45:58.208372 git.c:704 trace: exec: git-credential-cache get |
| 433 |
11:45:58.208919 run-command.c:663 trace: run_command: git-credential-cache get |
| 434 |
protocol=https |
| 435 |
host=github.com |
| 436 |
username=token |
| 437 |
password=secret |
| 438 |
|
| 439 |
❯ (echo url=https://[email protected]; echo ) | git credential reject |
| 440 |
11:47:03.921697 git.c:444 trace: built-in: git credential reject |
| 441 |
11:47:03.922530 run-command.c:663 trace: run_command: 'git credential-cache erase' |
| 442 |
11:47:03.935858 git.c:704 trace: exec: git-credential-cache erase |
| 443 |
11:47:03.936400 run-command.c:663 trace: run_command: git-credential-cache erase |
| 444 |
|
| 445 |
❯ (echo url=https://github.com; echo ) | git credential fill |
| 446 |
11:47:10.018877 git.c:444 trace: built-in: git credential fill |
| 447 |
11:47:10.019386 run-command.c:663 trace: run_command: 'git credential-cache get' |
| 448 |
11:47:10.027990 git.c:704 trace: exec: git-credential-cache get |
| 449 |
11:47:10.028572 run-command.c:663 trace: run_command: git-credential-cache get |
| 450 |
protocol=https |
| 451 |
host=github.com |
| 452 |
username=token2 |
| 453 |
password=secret2</code></pre></li> |
| 454 |
</ul> |
| 455 |
</div> |
| 456 |
<div id="store" class="section level2"> |
| 457 |
<h2><code>store</code></h2> |
| 458 |
<ul> |
| 459 |
<li><p>Docs: <a href="https://git-scm.com/docs/git-credential-store" class="uri">https://git-scm.com/docs/git-credential-store</a></p></li> |
| 460 |
<li><p>Configure for a repo:</p> |
| 461 |
<pre><code>❯ mkdir foo |
| 462 |
❯ cd foo |
| 463 |
❯ git init . |
| 464 |
11:53:48.042569 git.c:444 trace: built-in: git init . |
| 465 |
Initialized empty Git repository in /private/tmp/foo/.git/ |
| 466 |
|
| 467 |
❯ git config --add credential.helper "" |
| 468 |
11:53:52.949914 git.c:444 trace: built-in: git config --add credential.helper '' |
| 469 |
|
| 470 |
❯ git config --add credential.helper store |
| 471 |
11:53:56.682348 git.c:444 trace: built-in: git config --add credential.helper store |
| 472 |
|
| 473 |
❯ cat .git/config |
| 474 |
[core] |
| 475 |
repositoryformatversion = 0 |
| 476 |
filemode = true |
| 477 |
bare = false |
| 478 |
logallrefupdates = true |
| 479 |
ignorecase = true |
| 480 |
precomposeunicode = true |
| 481 |
[credential] |
| 482 |
helper = |
| 483 |
helper = store</code></pre></li> |
| 484 |
<li><p>Add credentials:</p> |
| 485 |
<pre><code>❯ (echo url=https://github.com; echo username=token; echo password=secret; echo ) | git credential approve |
| 486 |
11:54:44.184929 git.c:444 trace: built-in: git credential approve |
| 487 |
11:54:44.185729 run-command.c:663 trace: run_command: 'git credential-store store' |
| 488 |
11:54:44.197920 git.c:704 trace: exec: git-credential-store store |
| 489 |
11:54:44.198471 run-command.c:663 trace: run_command: git-credential-store store |
| 490 |
|
| 491 |
/tmp/foo master |
| 492 |
❯ (echo url=https://github.com; echo username=token2; echo password=secret2; echo ) | git credential approve |
| 493 |
11:54:48.452942 git.c:444 trace: built-in: git credential approve |
| 494 |
11:54:48.453399 run-command.c:663 trace: run_command: 'git credential-store store' |
| 495 |
11:54:48.463535 git.c:704 trace: exec: git-credential-store store |
| 496 |
11:54:48.464004 run-command.c:663 trace: run_command: git-credential-store store</code></pre></li> |
| 497 |
<li><p>Query with username:</p> |
| 498 |
<pre><code>❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 499 |
11:55:21.191654 git.c:444 trace: built-in: git credential fill |
| 500 |
11:55:21.192357 run-command.c:663 trace: run_command: 'git credential-store get' |
| 501 |
11:55:21.204279 git.c:704 trace: exec: git-credential-store get |
| 502 |
11:55:21.205063 run-command.c:663 trace: run_command: git-credential-store get |
| 503 |
protocol=https |
| 504 |
host=github.com |
| 505 |
username=token |
| 506 |
password=secret |
| 507 |
|
| 508 |
❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 509 |
11:55:24.194096 git.c:444 trace: built-in: git credential fill |
| 510 |
11:55:24.194654 run-command.c:663 trace: run_command: 'git credential-store get' |
| 511 |
11:55:24.207028 git.c:704 trace: exec: git-credential-store get |
| 512 |
11:55:24.207643 run-command.c:663 trace: run_command: git-credential-store get |
| 513 |
protocol=https |
| 514 |
host=github.com |
| 515 |
username=token2 |
| 516 |
password=secret2</code></pre></li> |
| 517 |
<li><p>Query without username returns <em>some</em> credentials, |
| 518 |
apparently not the ones that were set first:</p> |
| 519 |
<pre><code>❯ (echo url=https://github.com; echo ) | git credential fill |
| 520 |
11:56:12.394594 git.c:444 trace: built-in: git credential fill |
| 521 |
11:56:12.394949 run-command.c:663 trace: run_command: 'git credential-store get' |
| 522 |
11:56:12.403303 git.c:704 trace: exec: git-credential-store get |
| 523 |
11:56:12.403863 run-command.c:663 trace: run_command: git-credential-store get |
| 524 |
protocol=https |
| 525 |
host=github.com |
| 526 |
username=token2 |
| 527 |
password=secret2 |
| 528 |
|
| 529 |
❯ (echo url=https://[email protected]; echo ) | git credential reject |
| 530 |
11:56:24.065910 git.c:444 trace: built-in: git credential reject |
| 531 |
11:56:24.066314 run-command.c:663 trace: run_command: 'git credential-store erase' |
| 532 |
11:56:24.074851 git.c:704 trace: exec: git-credential-store erase |
| 533 |
11:56:24.076875 run-command.c:663 trace: run_command: git-credential-store erase |
| 534 |
|
| 535 |
❯ (echo url=https://github.com; echo ) | git credential fill |
| 536 |
11:56:26.438444 git.c:444 trace: built-in: git credential fill |
| 537 |
11:56:26.438839 run-command.c:663 trace: run_command: 'git credential-store get' |
| 538 |
11:56:26.446181 git.c:704 trace: exec: git-credential-store get |
| 539 |
11:56:26.446721 run-command.c:663 trace: run_command: git-credential-store get |
| 540 |
protocol=https |
| 541 |
host=github.com |
| 542 |
username=token |
| 543 |
password=secret</code></pre></li> |
| 544 |
</ul> |
| 545 |
</div> |
| 546 |
<div id="osxkeychain" class="section level2"> |
| 547 |
<h2><code>osxkeychain</code></h2> |
| 548 |
<ul> |
| 549 |
<li><p>Some docs: <a href="https://docs.github.com/en/github/using-git/updating-credentials-from-the-osx-keychain" class="uri">https://docs.github.com/en/github/using-git/updating-credentials-from-the-osx-keychain</a></p></li> |
| 550 |
<li><p>This is the default helper on macOS currently (git |
| 551 |
2.28.0).</p></li> |
| 552 |
<li><p>This is how it stores a credential:</p> |
| 553 |
<div class="sourceCode" id="cb10"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="ex">Name:</span> github.com</span> |
| 554 |
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a><span class="ex">Kind:</span> Internet password</span> |
| 555 |
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a><span class="ex">Account:</span> token</span> |
| 556 |
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a><span class="ex">Where:</span> https://github.com</span></code></pre></div></li> |
| 557 |
<li><p>It installs as a git subcommand, so it is possible to call its |
| 558 |
internal api directly:</p> |
| 559 |
<pre><code>❯ git credential-osxkeychain |
| 560 |
11:50:56.325499 git.c:704 trace: exec: git-credential-osxkeychain |
| 561 |
11:50:56.325783 run-command.c:663 trace: run_command: git-credential-osxkeychain |
| 562 |
usage: git credential-osxkeychain <get|store|erase></code></pre></li> |
| 563 |
<li><p>As always, needs <code>username</code> when setting the |
| 564 |
credential.</p></li> |
| 565 |
<li><p>No need to supply <code>username</code> to get <em>some</em> |
| 566 |
token that matches the host. This is in a clean keychain. First we set |
| 567 |
two credentials:</p> |
| 568 |
<div class="sourceCode" id="cb12"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> username=token<span class="kw">;</span> <span class="bu">echo</span> password=secret<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential approve</span> |
| 569 |
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:47.187164</span> git.c:444 trace: built-in: git credential approve</span> |
| 570 |
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:47.187691</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain store'</span></span> |
| 571 |
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:47.197964</span> git.c:704 trace: exec: git-credential-osxkeychain store</span> |
| 572 |
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:47.198518</span> run-command.c:663 trace: run_command: git-credential-osxkeychain store</span> |
| 573 |
<span id="cb12-6"><a href="#cb12-6" aria-hidden="true" tabindex="-1"></a></span> |
| 574 |
<span id="cb12-7"><a href="#cb12-7" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> username=token2<span class="kw">;</span> <span class="bu">echo</span> password=secret2<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential approve</span> |
| 575 |
<span id="cb12-8"><a href="#cb12-8" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:55.299933</span> git.c:444 trace: built-in: git credential approve</span> |
| 576 |
<span id="cb12-9"><a href="#cb12-9" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:55.300282</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain store'</span></span> |
| 577 |
<span id="cb12-10"><a href="#cb12-10" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:55.308568</span> git.c:704 trace: exec: git-credential-osxkeychain store</span> |
| 578 |
<span id="cb12-11"><a href="#cb12-11" aria-hidden="true" tabindex="-1"></a><span class="ex">10:48:55.309276</span> run-command.c:663 trace: run_command: git-credential-osxkeychain store</span></code></pre></div> |
| 579 |
<p>If we don’t supply a username, then we’ll just get one of them:</p> |
| 580 |
<div class="sourceCode" id="cb13"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential fill</span> |
| 581 |
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:17.371636</span> git.c:444 trace: built-in: git credential fill</span> |
| 582 |
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:17.372021</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain get'</span></span> |
| 583 |
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:17.378688</span> git.c:704 trace: exec: git-credential-osxkeychain get</span> |
| 584 |
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:17.379164</span> run-command.c:663 trace: run_command: git-credential-osxkeychain get</span> |
| 585 |
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a><span class="va">protocol</span><span class="op">=</span>https</span> |
| 586 |
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a><span class="va">host</span><span class="op">=</span>github.com</span> |
| 587 |
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a><span class="va">username</span><span class="op">=</span>token</span> |
| 588 |
<span id="cb13-9"><a href="#cb13-9" aria-hidden="true" tabindex="-1"></a><span class="va">password</span><span class="op">=</span>secret</span></code></pre></div> |
| 589 |
<p>If we supply the username, then we’ll get the correct one:</p> |
| 590 |
<div class="sourceCode" id="cb14"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://[email protected]<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential fill</span> |
| 591 |
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:28.613779</span> git.c:444 trace: built-in: git credential fill</span> |
| 592 |
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:28.614108</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain get'</span></span> |
| 593 |
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:28.621440</span> git.c:704 trace: exec: git-credential-osxkeychain get</span> |
| 594 |
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:28.621979</span> run-command.c:663 trace: run_command: git-credential-osxkeychain get</span> |
| 595 |
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a><span class="va">protocol</span><span class="op">=</span>https</span> |
| 596 |
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a><span class="va">host</span><span class="op">=</span>github.com</span> |
| 597 |
<span id="cb14-8"><a href="#cb14-8" aria-hidden="true" tabindex="-1"></a><span class="va">username</span><span class="op">=</span>token2</span> |
| 598 |
<span id="cb14-9"><a href="#cb14-9" aria-hidden="true" tabindex="-1"></a><span class="va">password</span><span class="op">=</span>secret2</span></code></pre></div> |
| 599 |
<p>To check that without a username we get an arbitrary one, let’s |
| 600 |
remove <code>token</code>:</p> |
| 601 |
<div class="sourceCode" id="cb15"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://[email protected]<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential reject</span> |
| 602 |
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:58.584332</span> git.c:444 trace: built-in: git credential reject</span> |
| 603 |
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:58.586880</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain erase'</span></span> |
| 604 |
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:58.598463</span> git.c:704 trace: exec: git-credential-osxkeychain erase</span> |
| 605 |
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a><span class="ex">10:49:58.599214</span> run-command.c:663 trace: run_command: git-credential-osxkeychain erase</span> |
| 606 |
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a></span> |
| 607 |
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="kw">```</span><span class="fu">sh</span></span> |
| 608 |
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential fill</span> |
| 609 |
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a><span class="ex">10:50:07.468385</span> git.c:444 trace: built-in: git credential fill</span> |
| 610 |
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a><span class="ex">10:50:07.468728</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain get'</span></span> |
| 611 |
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a><span class="ex">10:50:07.478398</span> git.c:704 trace: exec: git-credential-osxkeychain get</span> |
| 612 |
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a><span class="ex">10:50:07.478832</span> run-command.c:663 trace: run_command: git-credential-osxkeychain get</span> |
| 613 |
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a><span class="va">protocol</span><span class="op">=</span>https</span> |
| 614 |
<span id="cb15-14"><a href="#cb15-14" aria-hidden="true" tabindex="-1"></a><span class="va">host</span><span class="op">=</span>github.com</span> |
| 615 |
<span id="cb15-15"><a href="#cb15-15" aria-hidden="true" tabindex="-1"></a><span class="va">username</span><span class="op">=</span>token2</span> |
| 616 |
<span id="cb15-16"><a href="#cb15-16" aria-hidden="true" tabindex="-1"></a><span class="va">password</span><span class="op">=</span>secret2</span></code></pre></div> |
| 617 |
<p>Now let’s re-add token to make sure that <code>osxkeychain</code> |
| 618 |
does not prefer <code>token</code>:</p> |
| 619 |
<div class="sourceCode" id="cb16"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> username=token<span class="kw">;</span> <span class="bu">echo</span> password=secret<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential approve</span> |
| 620 |
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:52.302066</span> git.c:444 trace: built-in: git credential approve</span> |
| 621 |
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:52.311063</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain store'</span></span> |
| 622 |
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:52.321633</span> git.c:704 trace: exec: git-credential-osxkeychain store</span> |
| 623 |
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:52.322108</span> run-command.c:663 trace: run_command: git-credential-osxkeychain store</span> |
| 624 |
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a></span> |
| 625 |
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a><span class="ex">❯</span> <span class="er">(</span><span class="bu">echo</span> url=https://github.com<span class="kw">;</span> <span class="bu">echo</span> <span class="kw">)</span> <span class="kw">|</span> <span class="fu">git</span> credential fill</span> |
| 626 |
<span id="cb16-8"><a href="#cb16-8" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:57.316418</span> git.c:444 trace: built-in: git credential fill</span> |
| 627 |
<span id="cb16-9"><a href="#cb16-9" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:57.317630</span> run-command.c:663 trace: run_command: <span class="st">'git credential-osxkeychain get'</span></span> |
| 628 |
<span id="cb16-10"><a href="#cb16-10" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:57.330142</span> git.c:704 trace: exec: git-credential-osxkeychain get</span> |
| 629 |
<span id="cb16-11"><a href="#cb16-11" aria-hidden="true" tabindex="-1"></a><span class="ex">10:58:57.330697</span> run-command.c:663 trace: run_command: git-credential-osxkeychain get</span> |
| 630 |
<span id="cb16-12"><a href="#cb16-12" aria-hidden="true" tabindex="-1"></a><span class="va">protocol</span><span class="op">=</span>https</span> |
| 631 |
<span id="cb16-13"><a href="#cb16-13" aria-hidden="true" tabindex="-1"></a><span class="va">host</span><span class="op">=</span>github.com</span> |
| 632 |
<span id="cb16-14"><a href="#cb16-14" aria-hidden="true" tabindex="-1"></a><span class="va">username</span><span class="op">=</span>token2</span> |
| 633 |
<span id="cb16-15"><a href="#cb16-15" aria-hidden="true" tabindex="-1"></a><span class="va">password</span><span class="op">=</span>secret2</span></code></pre></div> |
| 634 |
<p>So it seems that <code>osxkeychain</code> will just find an arbitrary |
| 635 |
one, or the one that was added first.</p></li> |
| 636 |
</ul> |
| 637 |
</div> |
| 638 |
<div id="manager-core-on-macos-before-version-2.0.246-beta" class="section level2"> |
| 639 |
<h2><code>manager-core</code> (on macOS), before version |
| 640 |
2.0.246-beta</h2> |
| 641 |
<ul> |
| 642 |
<li><p>Not installed by default (git 2.28.0).</p></li> |
| 643 |
<li><p>Install from brew, according to the instructions: <a href="https://github.com/GitCredentialManager/git-credential-manager#macos-homebrew" class="uri">https://github.com/GitCredentialManager/git-credential-manager#macos-homebrew</a></p></li> |
| 644 |
<li><p>If updates your global git config, adding these lines:</p> |
| 645 |
<div class="sourceCode" id="cb17"><pre class="sourceCode sh"><code class="sourceCode bash"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a><span class="ex">[credential]</span></span> |
| 646 |
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="ex">helper</span> = <span class="st">""</span></span> |
| 647 |
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a><span class="ex">[credential</span> <span class="st">"https://dev.azure.com"</span>]</span> |
| 648 |
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a> <span class="ex">useHttpPath</span> = true</span> |
| 649 |
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a><span class="ex">[credential]</span></span> |
| 650 |
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a> <span class="ex">helper</span> = manager-core</span></code></pre></div> |
| 651 |
<p>The <code>helper = ""</code> line deletes previous handlers. The |
| 652 |
system helper is kept as <code>osxkeychain</code>.</p></li> |
| 653 |
<li><p>It installs as a git subcommand, and you can call its internal |
| 654 |
API directly:</p> |
| 655 |
<pre><code>❯ git credential-manager-core |
| 656 |
11:51:56.434300 git.c:704 trace: exec: git-credential-manager-core |
| 657 |
11:51:56.434496 run-command.c:663 trace: run_command: git-credential-manager-core |
| 658 |
Missing command. |
| 659 |
|
| 660 |
usage: git-credential-manager-core <command> |
| 661 |
|
| 662 |
Available commands: |
| 663 |
erase |
| 664 |
get |
| 665 |
store |
| 666 |
|
| 667 |
configure [--system] |
| 668 |
unconfigure [--system] |
| 669 |
|
| 670 |
--version, version |
| 671 |
--help, -h, -?</code></pre></li> |
| 672 |
<li><p>It is not compatible with the <code>osxkeychain</code> helper, |
| 673 |
because it uses different keys in the keychain.</p></li> |
| 674 |
<li><p>It supports different <em>providers</em>. Providers are |
| 675 |
auto-detected by default. GitHub has its own provider, detected via the |
| 676 |
<code>github.com</code> URL. The provider can be configured user a git |
| 677 |
config key or an environment variable: <a href="https://github.com/GitCredentialManager/git-credential-manager/blob/master/docs/configuration.md" class="uri">https://github.com/GitCredentialManager/git-credential-manager/blob/master/docs/configuration.md</a></p></li> |
| 678 |
<li><p>It does not currently supports namepaces (like |
| 679 |
<code>manager</code>).</p></li> |
| 680 |
<li><p>This is how it stores a credential:</p> |
| 681 |
<pre><code>Name: git:https://github.com |
| 682 |
Kind: application password |
| 683 |
Account: token |
| 684 |
Where: git:https://github.com</code></pre></li> |
| 685 |
<li><p>No need to supply <code>username</code> to get <em>some</em> |
| 686 |
credential:</p> |
| 687 |
<pre><code>❯ (echo url=https://github.com; echo ) | git credential fill |
| 688 |
11:24:47.750966 git.c:444 trace: built-in: git credential fill |
| 689 |
11:24:47.753268 run-command.c:663 trace: run_command: 'git credential-manager-core get' |
| 690 |
11:24:47.762249 git.c:704 trace: exec: git-credential-manager-core get |
| 691 |
11:24:47.762917 run-command.c:663 trace: run_command: git-credential-manager-core get |
| 692 |
protocol=https |
| 693 |
host=github.com |
| 694 |
username=token |
| 695 |
password=secret</code></pre></li> |
| 696 |
<li><p>If there are multiple credentials, a random one (or the one set |
| 697 |
first?) is returned:</p> |
| 698 |
<pre><code>❯ (echo url=https://github.com; echo username=token2; echo password=secret2; echo ) | git credential approve |
| 699 |
11:25:41.553761 git.c:444 trace: built-in: git credential approve |
| 700 |
11:25:41.554242 run-command.c:663 trace: run_command: 'git credential-manager-core store' |
| 701 |
11:25:41.565748 git.c:704 trace: exec: git-credential-manager-core store |
| 702 |
11:25:41.566218 run-command.c:663 trace: run_command: git-credential-manager-core store</code></pre></li> |
| 703 |
<li><p>In fact the username is completely ignored when getting |
| 704 |
credentials, at least for the GitHub provider:</p> |
| 705 |
<pre><code>❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 706 |
11:29:49.274574 git.c:444 trace: built-in: git credential fill |
| 707 |
11:29:49.275020 run-command.c:663 trace: run_command: 'git credential-manager-core get' |
| 708 |
11:29:49.283563 git.c:704 trace: exec: git-credential-manager-core get |
| 709 |
11:29:49.284236 run-command.c:663 trace: run_command: git-credential-manager-core get |
| 710 |
protocol=https |
| 711 |
host=github.com |
| 712 |
username=token |
| 713 |
password=secret</code></pre> |
| 714 |
<p>This is because the username is not stored as part of the URL by the |
| 715 |
GitHub provider. Related issue: <a href="https://github.com/GitCredentialManager/git-credential-manager/issues/160" class="uri">https://github.com/GitCredentialManager/git-credential-manager/issues/160</a> |
| 716 |
<code>manager</code> has a similar problem, it is linked from this |
| 717 |
GitHub issue.</p></li> |
| 718 |
<li><p>If you set the provider to Generic, then usernames work as |
| 719 |
expected. In this case, this is stored in the keychain:</p> |
| 720 |
<pre><code>Name: git:https://[email protected]/ |
| 721 |
Kind: application password |
| 722 |
Account: token |
| 723 |
Where: git:https://[email protected]/</code></pre> |
| 724 |
<p>These credentials are not compatible with the ones set by the GitHub |
| 725 |
provider.</p> |
| 726 |
<pre><code>❯ export GCM_PROVIDER=generic |
| 727 |
|
| 728 |
❯ (echo url=https://github.com; echo username=token; echo password=secret; echo ) | git credential approve |
| 729 |
11:34:15.998644 git.c:444 trace: built-in: git credential approve |
| 730 |
11:34:15.998992 run-command.c:663 trace: run_command: 'git credential-manager-core store' |
| 731 |
11:34:16.008178 git.c:704 trace: exec: git-credential-manager-core store |
| 732 |
11:34:16.008834 run-command.c:663 trace: run_command: git-credential-manager-core store |
| 733 |
|
| 734 |
❯ (echo url=https://github.com; echo username=token2; echo password=secret2; echo ) | git credential approve |
| 735 |
11:35:52.629963 git.c:444 trace: built-in: git credential approve |
| 736 |
11:35:52.637966 run-command.c:663 trace: run_command: 'git credential-manager-core store' |
| 737 |
11:35:52.648058 git.c:704 trace: exec: git-credential-manager-core store |
| 738 |
11:35:52.648514 run-command.c:663 trace: run_command: git-credential-manager-core store |
| 739 |
|
| 740 |
❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 741 |
11:35:58.336428 git.c:444 trace: built-in: git credential fill |
| 742 |
11:35:58.336881 run-command.c:663 trace: run_command: 'git credential-manager-core get' |
| 743 |
11:35:58.345187 git.c:704 trace: exec: git-credential-manager-core get |
| 744 |
11:35:58.345729 run-command.c:663 trace: run_command: git-credential-manager-core get |
| 745 |
protocol=https |
| 746 |
host=github.com |
| 747 |
username=token |
| 748 |
password=secret |
| 749 |
|
| 750 |
❯ (echo url=https://[email protected]; echo ) | git credential fill |
| 751 |
11:36:02.550339 git.c:444 trace: built-in: git credential fill |
| 752 |
11:36:02.550695 run-command.c:663 trace: run_command: 'git credential-manager-core get' |
| 753 |
11:36:02.557777 git.c:704 trace: exec: git-credential-manager-core get |
| 754 |
11:36:02.558359 run-command.c:663 trace: run_command: git-credential-manager-core get |
| 755 |
protocol=https |
| 756 |
host=github.com |
| 757 |
username=token2 |
| 758 |
password=secret2</code></pre></li> |
| 759 |
</ul> |
| 760 |
</div> |
| 761 |
<div id="manager-core-macos-2.0.246-beta-or-later" class="section level2"> |
| 762 |
<h2><code>manager-core</code> (macOS), 2.0.246-beta or later</h2> |
| 763 |
<ul> |
| 764 |
<li>This version adds better support for multiple credentials for the |
| 765 |
same host.</li> |
| 766 |
<li>It does not save the <code>username</code> as part of the service |
| 767 |
any more, for the generic provider.</li> |
| 768 |
<li>It does save the <code>username</code> as <code>account</code> and |
| 769 |
it uses it when searching for credentials, both for the |
| 770 |
<code>generic</code> and the <code>github</code> provider.</li> |
| 771 |
</ul> |
| 772 |
</div> |
| 773 |
<div id="manager-github-authority" class="section level2"> |
| 774 |
<h2><code>manager</code> (GitHub authority)</h2> |
| 775 |
<ul> |
| 776 |
<li><p>This was Git Credential Manager for Windows, and it is the |
| 777 |
default helper on Windows for git 2.28.0. In git 2.29.0 it is not the |
| 778 |
default any more, and it is deprecated in favor of |
| 779 |
<code>manager-core</code>. It is still installed, though.</p></li> |
| 780 |
<li><p>Docs: <a href="https://github.com/Microsoft/Git-Credential-Manager-for-Windows" class="uri">https://github.com/Microsoft/Git-Credential-Manager-for-Windows</a></p></li> |
| 781 |
<li><p>It is installed as a git subcommand, so it can be called |
| 782 |
directly:</p> |
| 783 |
<pre><code>❯ $env:GIT_TRACE="true" |
| 784 |
❯ git credential-manager |
| 785 |
12:15:45.554298 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 786 |
12:15:45.556249 git.c:704 trace: exec: git-credential-manager |
| 787 |
12:15:45.556249 run-command.c:663 trace: run_command: git-credential-manager |
| 788 |
usage: git-credential-manager.exe [approve|clear|config|delete|deploy|erase|fill|get|install|reject|remove|store|uninstall|version] [<args>] |
| 789 |
fatal: Unable to open help documentation.</code></pre></li> |
| 790 |
<li><p>Setting credentials. The <code>username</code> must be provided, |
| 791 |
and it is stored in the credential, but the GitHub provider overwrites |
| 792 |
credentials with the same host name, even if they have a different |
| 793 |
<code>username</code>. I.e. after this, there will be only one |
| 794 |
credential:</p> |
| 795 |
<pre><code>❯ % { echo url=https://github.com; echo username=token; echo password=secret; echo "" } | git credential approve |
| 796 |
13:16:58.118611 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 797 |
13:16:58.120617 git.c:444 trace: built-in: git credential approve |
| 798 |
13:16:58.122612 run-command.c:663 trace: run_command: 'git credential-manager store' |
| 799 |
13:16:58.170625 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 800 |
13:16:58.173087 git.c:704 trace: exec: git-credential-manager store |
| 801 |
13:16:58.173087 run-command.c:663 trace: run_command: git-credential-manager store |
| 802 |
|
| 803 |
❯ % { echo url=https://github.com; echo username=token2; echo password=secret2; echo "" } | git credential approve |
| 804 |
13:17:30.925970 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 805 |
13:17:30.928134 git.c:444 trace: built-in: git credential approve |
| 806 |
13:17:30.928987 run-command.c:663 trace: run_command: 'git credential-manager store' |
| 807 |
13:17:30.968981 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 808 |
13:17:30.970974 git.c:704 trace: exec: git-credential-manager store |
| 809 |
13:17:30.970974 run-command.c:663 trace: run_command: git-credential-manager store</code></pre></li> |
| 810 |
<li><p>It stores credentials in the following format:</p> |
| 811 |
<pre><code>Internet or network address: git:https://github.com |
| 812 |
User name: token |
| 813 |
Password: **** |
| 814 |
Persistence: Local computer</code></pre></li> |
| 815 |
</ul> |
| 816 |
<p><!- - –></p> |
| 817 |
<ul> |
| 818 |
<li><p>It has multiple authorities, (like providers for |
| 819 |
<code>manager-core</code>). The GitHub authority is used for |
| 820 |
<code>github.com</code> URLs by default. The authority can be set with a |
| 821 |
config option or an env var.</p></li> |
| 822 |
<li><p>We need to set the <code>GCM_VALIDATE</code> env var to |
| 823 |
<code>false</code> , otherwise it tries to validate the GitHub token |
| 824 |
every time we query it.</p> |
| 825 |
<pre><code>❯ $env:GCM_VALIDATE="false"</code></pre></li> |
| 826 |
<li><p>No <code>username</code> is needed for getting <em>the</em> |
| 827 |
credential, for the GitHub provider.</p> |
| 828 |
<pre><code>❯ % { echo url=https://github.com; echo "" } | git credential fill |
| 829 |
13:24:43.831089 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 830 |
13:24:43.833666 git.c:444 trace: built-in: git credential fill |
| 831 |
13:24:43.834092 run-command.c:663 trace: run_command: 'git credential-manager get' |
| 832 |
13:24:43.872087 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 833 |
13:24:43.874092 git.c:704 trace: exec: git-credential-manager get |
| 834 |
13:24:43.874092 run-command.c:663 trace: run_command: git-credential-manager get |
| 835 |
protocol=https |
| 836 |
host=github.com |
| 837 |
path= |
| 838 |
username=token2 |
| 839 |
password=secret2</code></pre> |
| 840 |
<p>In fact the <code>username</code> is ignored for the GitHub |
| 841 |
provider:</p> |
| 842 |
<pre><code>❯ % { echo url=https://[email protected]; echo "" } | git credential fill |
| 843 |
13:25:06.029084 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 844 |
13:25:06.031084 git.c:444 trace: built-in: git credential fill |
| 845 |
13:25:06.032081 run-command.c:663 trace: run_command: 'git credential-manager get' |
| 846 |
13:25:06.069085 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 847 |
13:25:06.070086 git.c:704 trace: exec: git-credential-manager get |
| 848 |
13:25:06.070086 run-command.c:663 trace: run_command: git-credential-manager get |
| 849 |
protocol=https |
| 850 |
host=github.com |
| 851 |
path= |
| 852 |
username=token2 |
| 853 |
password=secret2</code></pre></li> |
| 854 |
<li><p>Supports namespaces, the default namespace is <code>git</code>. |
| 855 |
The namespace is included in the name of the credential: |
| 856 |
<code>namespace:URL</code>.</p></li> |
| 857 |
<li><p>There is a pull request to include the <code>username</code> in |
| 858 |
the URL as well: <a href="https://github.com/microsoft/Git-Credential-Manager-for-Windows/pull/891" class="uri">https://github.com/microsoft/Git-Credential-Manager-for-Windows/pull/891</a></p></li> |
| 859 |
</ul> |
| 860 |
</div> |
| 861 |
<div id="manager-basic-authority" class="section level2"> |
| 862 |
<h2><code>manager</code> (Basic authority)</h2> |
| 863 |
<ul> |
| 864 |
<li><p><code>Basic</code> authority can be configured with an env var or |
| 865 |
config option:</p> |
| 866 |
<pre><code>❯ $env:GCM_AUTHORITY="Basic"</code></pre></li> |
| 867 |
<li><p>It is compatible with the credentials set by the |
| 868 |
<code>GitHub</code> authority:</p> |
| 869 |
<pre><code>❯ % { echo url=https://github.com; echo "" } | git credential fill |
| 870 |
13:27:17.344396 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 871 |
13:27:17.346397 git.c:444 trace: built-in: git credential fill |
| 872 |
13:27:17.347388 run-command.c:663 trace: run_command: 'git credential-manager get' |
| 873 |
13:27:17.386388 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 874 |
13:27:17.388386 git.c:704 trace: exec: git-credential-manager get |
| 875 |
13:27:17.388386 run-command.c:663 trace: run_command: git-credential-manager get |
| 876 |
protocol=https |
| 877 |
host=github.com |
| 878 |
path= |
| 879 |
username=token2 |
| 880 |
password=secret2</code></pre></li> |
| 881 |
<li><p>But it supports usernames as well. Note that since the username |
| 882 |
is stored in the URL, it does not return some arbitrary credentials if |
| 883 |
we query the URL without a username. We need to tell GCM here not to ask |
| 884 |
for a password, but just fall back to the next credential helper.</p> |
| 885 |
<pre><code>❯ $env:GCM_INTERACTIVE="Never" |
| 886 |
|
| 887 |
❯ % { echo url=https://[email protected]; echo "" } | git -c credential.helper="! echo protocol=dummy; echo host=dummy; |
| 888 |
echo username=dummy; echo password=dummy" credential fill |
| 889 |
13:31:16.682545 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 890 |
13:31:16.684473 git.c:444 trace: built-in: git credential fill |
| 891 |
13:31:16.685471 run-command.c:663 trace: run_command: 'git credential-manager get' |
| 892 |
13:31:16.725486 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 893 |
13:31:16.727472 git.c:704 trace: exec: git-credential-manager get |
| 894 |
13:31:16.727472 run-command.c:663 trace: run_command: git-credential-manager get |
| 895 |
Logon failed, use ctrl+c to cancel basic credential prompt. |
| 896 |
13:31:16.948468 run-command.c:663 trace: run_command: ' echo protocol=dummy; echo host=dummy; echo username=dummy; echo password=dummy get' |
| 897 |
protocol=dummy |
| 898 |
host=dummy |
| 899 |
username=dummy |
| 900 |
password=dummy get</code></pre></li> |
| 901 |
<li><p>When setting credentials, usernames are included in the URL:</p> |
| 902 |
<pre><code>❯ % { echo url=https://github.com; echo username=token; echo password=secret; echo "" } | git credential approve |
| 903 |
13:34:37.937934 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 904 |
13:34:37.940820 git.c:444 trace: built-in: git credential approve |
| 905 |
13:34:37.940995 run-command.c:663 trace: run_command: 'git credential-manager store' |
| 906 |
13:34:37.983372 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 907 |
13:34:37.984737 git.c:704 trace: exec: git-credential-manager store |
| 908 |
13:34:37.984737 run-command.c:663 trace: run_command: git-credential-manager store</code></pre> |
| 909 |
<p>will create this record in the credential store:</p> |
| 910 |
<pre><code>Internet or network address: git:https://[email protected] |
| 911 |
User name: token |
| 912 |
Password: **** |
| 913 |
Persistence: Local computer</code></pre> |
| 914 |
<p>and then this can be queried with an explicit username:</p> |
| 915 |
<pre><code>❯ % { echo url=https://[email protected]; echo "" } | git -c credential.helper="! echo protocol=dummy; echo host=dummy; echo username=dummy; echo password=dummy" credential fill |
| 916 |
13:36:42.789268 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/bin |
| 917 |
13:36:42.791270 git.c:444 trace: built-in: git credential fill |
| 918 |
13:36:42.792266 run-command.c:663 trace: run_command: 'git credential-manager get' |
| 919 |
13:36:42.830475 exec-cmd.c:237 trace: resolved executable dir: C:/Program Files/Git/mingw64/libexec/git-core |
| 920 |
13:36:42.832279 git.c:704 trace: exec: git-credential-manager get |
| 921 |
13:36:42.832279 run-command.c:663 trace: run_command: git-credential-manager get |
| 922 |
protocol=https |
| 923 |
host=github.com |
| 924 |
path= |
| 925 |
username=token |
| 926 |
password=secret</code></pre></li> |
| 927 |
</ul> |
| 928 |
</div> |
| 929 |
<div id="manager-core-on-windows-before-version-2.0.246-beta" class="section level2"> |
| 930 |
<h2><code>manager-core</code> (on Windows, before version |
| 931 |
2.0.246-beta)</h2> |
| 932 |
<ul> |
| 933 |
<li><p>Not installed by default (git 2.28.0), but this is supposed to be |
| 934 |
the future canonical implementation. See above for the macOS |
| 935 |
version.</p></li> |
| 936 |
<li><p>It works similarly to <code>manager</code> , I haven’t seen any |
| 937 |
differences in behavior (version was 2.0.194.40577). Instead of |
| 938 |
authorities, we need to set up providers: <a href="https://github.com/GitCredentialManager/git-credential-manager/blob/master/docs/migration.md" class="uri">https://github.com/GitCredentialManager/git-credential-manager/blob/master/docs/migration.md</a>. |
| 939 |
The <code>Generic</code> provider works the same way as the |
| 940 |
<code>Basic</code> authority in <code>manager</code>.</p></li> |
| 941 |
<li><p>Unfortunately setting <code>GCM_AUTHORITY</code> will make |
| 942 |
<code>manager-core</code> break, so it is not possible to use both |
| 943 |
<code>manager</code> and <code>manager-core</code> if you need to set |
| 944 |
this environment variable.</p></li> |
| 945 |
</ul> |
| 946 |
</div> |
| 947 |
<div id="manager-core-on-windows-from-2.0.246-beta" class="section level2"> |
| 948 |
<h2><code>manager-core</code> (on Windows, from 2.0.246-beta)</h2> |
| 949 |
<ul> |
| 950 |
<li>This is now the version that is the default helper in git 2.29.0 and |
| 951 |
later. <code>manager</code> is still installed, but the default system |
| 952 |
config sets <code>manager-core</code>.</li> |
| 953 |
<li>It supports multiple users better: <a href="https://github.com/GitCredentialManager/git-credential-manager/issues/160#issuecomment-700544889" class="uri">https://github.com/GitCredentialManager/git-credential-manager/issues/160#issuecomment-700544889</a></li> |
| 954 |
<li>When storing a credential, it first checks if there is a target name |
| 955 |
without a username. If there is, then it uses the target name without |
| 956 |
the username. It stores the username in the <code>username</code> field |
| 957 |
of the credential, still. so it is not lost.</li> |
| 958 |
<li>When looking up a credential without a username, it will return the |
| 959 |
first credential it can find, even if the target name contains a |
| 960 |
username, and there is another credential without a username in the |
| 961 |
target name.</li> |
| 962 |
<li>When looking up a credential with a username, it may return any |
| 963 |
credential with a matching username, and a target name that matches the |
| 964 |
host. The username inside the target name does not actually matter.</li> |
| 965 |
</ul> |
| 966 |
</div> |
| 967 |
</div> |
| 968 |
<div id="recommendations-for-multiple-accounts" class="section level1"> |
| 969 |
<h1>Recommendations for multiple accounts</h1> |
| 970 |
<div id="macos" class="section level2"> |
| 971 |
<h2>macOS</h2> |
| 972 |
<ol style="list-style-type: decimal"> |
| 973 |
<li><p>Use the <code>osxkeychain</code> helper.</p></li> |
| 974 |
<li><p>FIrst remove all your current credentials for the host you are |
| 975 |
targeting. E.g. for GitHub, search for “Internet Passwords” for |
| 976 |
github.com, or use <code>gitcreds::gitcreds_list()</code> and the |
| 977 |
oskeyring package to remove them. You can also use the oskeyring package |
| 978 |
to back up the tokens and passwords.</p></li> |
| 979 |
<li><p>Then add the credential that you want to use for “generic |
| 980 |
access”. This is the credential that will be used for URLs without user |
| 981 |
names. The user name for this credential does not matter, but you can |
| 982 |
choose something descriptive, e.g. “PersonalAccessToken”, “token”, or |
| 983 |
“generic”.</p></li> |
| 984 |
<li><p>Configure git to use this username by default. E.g. if you chose |
| 985 |
“generic”, then run</p> |
| 986 |
<pre><code>git config --global credential.username generic</code></pre></li> |
| 987 |
<li><p>Add all the other credentials, with appropriate user names. These |
| 988 |
are the user names that you need to put in the URLs for the repositories |
| 989 |
or operations you want to use them for. (GitHub does not actually use |
| 990 |
the user names if the password is a PAT.)</p></li> |
| 991 |
</ol> |
| 992 |
</div> |
| 993 |
<div id="windows-with-git-2.29.0-or-later-and-manager-core" class="section level2"> |
| 994 |
<h2>Windows, with git 2.29.0 or later and manager-core</h2> |
| 995 |
<ol style="list-style-type: decimal"> |
| 996 |
<li><p>We suggest that you update to the latest git version, but at |
| 997 |
least 2.29.0, and use the <code>manager-core</code> helper which is now |
| 998 |
default. If you installed <code>manager-core</code> separately from git, |
| 999 |
we suggest that you remove it, because it might cause confusion as to |
| 1000 |
which helper is actually used.</p></li> |
| 1001 |
<li><p>Remove all current credentials first, for the host you are |
| 1002 |
targeting. You can do this in ‘Credential Manager’ or |
| 1003 |
<code>gitcreds::gitcreds_list()</code> to find them and the oskeyring |
| 1004 |
package to remove them. You can also use the oskeyring packaeg to back |
| 1005 |
up the tokens and passwords.</p></li> |
| 1006 |
<li><p>Then add the credential that you want to use for “generic |
| 1007 |
access”. This is the credential that will be used for URLs without user |
| 1008 |
names. The user name for this credential does not matter, but you can |
| 1009 |
choose something descriptive, e.g. “PersonalAccessToken”, “token”, or |
| 1010 |
“generic”.</p></li> |
| 1011 |
<li><p>Configure git to use this username by default. E.g. if you chose |
| 1012 |
“generic”, then run</p> |
| 1013 |
<p>git config –global credential.username generic</p></li> |
| 1014 |
<li><p>Add all the other credentials, with appropriate user names. These |
| 1015 |
are the user names that you need to put in the URLs for the repositories |
| 1016 |
or operations you want to use them for. (GitHub does not actually use |
| 1017 |
the user names if the password is a PAT.)</p></li> |
| 1018 |
</ol> |
| 1019 |
</div> |
| 1020 |
<div id="windows-with-older-git-versions" class="section level2"> |
| 1021 |
<h2>Windows with older git versions</h2> |
| 1022 |
<div id="at-most-one-github.com-credential" class="section level3"> |
| 1023 |
<h3>At most one github.com credential</h3> |
| 1024 |
<p>If you only need to manage a single github.com credential, together |
| 1025 |
with possibly multiple credentials to other hosts (including GitHub |
| 1026 |
Enterprise hosts), then you can use the default <code>manager</code> |
| 1027 |
helper, and get away with the default auto-detected GCM authority |
| 1028 |
setting.</p> |
| 1029 |
<p>In this case, you can add you github.com credential with an arbitrary |
| 1030 |
user name, and for each other host you can add configure a default user |
| 1031 |
name, and/or include user names in the URLs to these hosts. This is how |
| 1032 |
to set a default user name for a host:</p> |
| 1033 |
<pre><code>git config --global credential.https://example.com.username myusername</code></pre> |
| 1034 |
</div> |
| 1035 |
<div id="multiple-github-credentials" class="section level3"> |
| 1036 |
<h3>Multiple GitHub credentials</h3> |
| 1037 |
<p>If you need to manage multiple github.com credentials, then you can |
| 1038 |
still use the <code>manager</code> helper, but you need to change the |
| 1039 |
GCM authority by setting an option or an environment variable, see <a href="https://github.com/microsoft/Git-Credential-Manager-for-Windows/blob/master/Docs/Configuration.md#authority." class="uri">https://github.com/microsoft/Git-Credential-Manager-for-Windows/blob/master/Docs/Configuration.md#authority.</a> |
| 1040 |
Once <a href="https://github.com/microsoft/Git-Credential-Manager-for-Windows/pull/891" class="uri">https://github.com/microsoft/Git-Credential-Manager-for-Windows/pull/891</a> |
| 1041 |
is merged, you won’t need to do this. (At least in recent git versions, |
| 1042 |
that contain a GCM build with the fix.)</p> |
| 1043 |
<p>This is how to change the config for this:</p> |
| 1044 |
<pre><code>git config --global credential.authority Basic</code></pre> |
| 1045 |
<p>You can also change it only for github.com:</p> |
| 1046 |
<pre><code>git config --global credential.github.com.authority Basic</code></pre> |
| 1047 |
<p>Then you can configure a default user name, this will be used for |
| 1048 |
URLs without a user name:</p> |
| 1049 |
<pre><code>git config --global credential.username generic</code></pre> |
| 1050 |
<p>Now you can add you credentials, the default one with the “generic” |
| 1051 |
user name, and all the others with their specific user and host |
| 1052 |
names.</p> |
| 1053 |
</div> |
| 1054 |
</div> |
| 1055 |
</div> |
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
<!-- code folding --> |
| 1060 |
|
| 1061 |
|
| 1062 |
<!-- dynamically load mathjax for compatibility with self-contained --> |
| 1063 |
<script> |
| 1064 |
(function () { |
| 1065 |
var script = document.createElement("script"); |
| 1066 |
script.type = "text/javascript"; |
| 1067 |
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"; |
| 1068 |
document.getElementsByTagName("head")[0].appendChild(script); |
| 1069 |
})(); |
| 1070 |
</script> |
| 1071 |
|
| 1072 |
</body> |
| 1073 |
</html> |