{"thread":{"id":"41562","subject":"Git 2.7.2.windows.1 fails to authenticate access to private repository over HTTPS","startedAt":"2016-02-29T03:24:32Z","lastAt":"2016-02-29T13:30:08Z","messageCount":2,"participants":["zacr","Johannes Schindelin"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"279739","messageId":"0eee43fe410bb5db3dc8eeec2f7ff00c@slingshot.co.nz","threadId":"41562","inReplyTo":null,"subject":"Git 2.7.2.windows.1 fails to authenticate access to private repository over HTTPS","fromName":"zacr","fromEmail":"zacr@slingshot.co.nz","sentAt":"2016-02-29T03:24:32Z","receivedAt":"2016-02-29T03:24:32Z","isPatch":false,"sender":{"key":"zacr@slingshot.co.nz","avatar":null},"body":"Hi,\n\nI have recently downloaded 64-bit Git for Windows (the file I downloaded \nwas \"Git-2.7.2-64-bit.exe\"). This reports a version string of \"git \nversion 2.7.2.windows.1\"\nUsing it from the command line, after cloning a repository, I attempted \nto \"git pull\" a private repository from GitHub. From prior experience, I \nexpected it to ask me for my username and password, then authenticate \nwith the server. It asked for my username, which I typed in, but after \npressing Enter it suddenly failed with an error:\n\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username for 'https://github.com': Invalid \nargument\n\n\nI experimented a bit, and it only occurs when trying to use HTTPS to \npull from a repository that requires authentication. Using a personal \naccess token to authenticate or using the git protocol both work.\n\nI ran it again with GIT_TRACE=true, and here is the trace (with username \nand repository name removed):\n\n15:55:58.615147 git.c:348               trace: built-in: git 'pull'\n15:55:58.617147 run-command.c:343       trace: run_command: 'fetch' \n'--update-head-ok'\n15:55:58.633149 git.c:348               trace: built-in: git 'fetch' \n'--update-head-ok'\n15:55:58.636149 run-command.c:343       trace: run_command: \n'git-remote-https' 'origin' 'https://github.com/username/repository.git'\n15:55:59.630248 run-command.c:343       trace: run_command: 'bash' '-c' \n'cat >/dev/tty && read -r line </dev/tty && echo \"$line\"'\nerror: failed to execute prompt script (exit code 1)\nfatal: could not read Username for 'https://github.com': Invalid \nargument\n\n\nIt looks like it's trying to run a new bash instance for me to enter my \npassword, which fails on Windows because I don't have bash installed.\n\n\n\nFor reference, here are some old threads I found while researching the \nissue. It looks like this has cropped up before, in Git 1.8.5.\nhttps://groups.google.com/forum/#!msg/msysgit/s4dB8Nv9V4c/55-cGPdPYmAJ\nhttps://github.com/msysgit/msysgit/issues/153\nand stackoverflow for good measure (comments by Mr_and_Mrs_D, Ricardo, \nand AndyL identify it as a bug with 1.8.5):\nhttp://stackoverflow.com/questions/20871549/error-when-push-commits-with-github-fatal-could-not-read-username\n\n\nI would appreciate your help.\n\n\nYours sincerely,\nZac Roberts\nzacr@slingshot.co.nz\n"},{"id":"279777","messageId":"alpine.DEB.2.20.1602291405150.3152@virtualbox","threadId":"41562","inReplyTo":"0eee43fe410bb5db3dc8eeec2f7ff00c@slingshot.co.nz","subject":"Re: Git 2.7.2.windows.1 fails to authenticate access to private repository over HTTPS","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2016-02-29T13:30:08Z","receivedAt":"2016-02-29T13:30:08Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Zac,\n\nOn Mon, 29 Feb 2016, zacr wrote:\n\n> I have recently downloaded 64-bit Git for Windows (the file I downloaded\n> was \"Git-2.7.2-64-bit.exe\"). This reports a version string of \"git\n> version 2.7.2.windows.1\"\n>\n> Using it from the command line, after cloning a repository, I attempted\n> to \"git pull\" a private repository from GitHub.\n\nAre you using Git CMD? It is rather crucial to get such details right.\n\n> 15:55:58.615147 git.c:348               trace: built-in: git 'pull'\n> 15:55:58.617147 run-command.c:343       trace: run_command: 'fetch'\n> '--update-head-ok'\n> 15:55:58.633149 git.c:348               trace: built-in: git 'fetch'\n> '--update-head-ok'\n> 15:55:58.636149 run-command.c:343       trace: run_command:\n> 'git-remote-https' 'origin' 'https://github.com/username/repository.git'\n> 15:55:59.630248 run-command.c:343       trace: run_command: 'bash' '-c' 'cat\n> >/dev/tty && read -r line </dev/tty && echo \"$line\"'\n> error: failed to execute prompt script (exit code 1)\n> fatal: could not read Username for 'https://github.com': Invalid argument\n> \n> \n> It looks like it's trying to run a new bash instance for me to enter my\n> password, which fails on Windows because I don't have bash installed.\n\nYou do have bash installed. Unless you went out of your way to delete it\nafter installing Git for Windows.\n\nAssuming that you used Git CMD to perform your test, the sad news is that\nI cannot reproduce your problem here.\n\nLet's first of all try to make a Minimal, Complete & Verifiable Example\n(MCVE). In other words, let's find the minimal set of steps with no\nprerequisites (such as local clones of private repositories) that *still*\nreproduce the bug. This is in general a Very Good Idea if you are\nreporting bugs because it not only shows that you are dedicated to see\nthis bug fixed but also that you are not expecting only others to invest\na ton of time into the bug fix.\n\nIn your case, the problem is easily triggered without a local clone at\nall. A simple `git ls-remote https://github.com/user/repository.git` is\nenough, and would count as *Minimal* as per that MCVE acronym.\n\nAlas, when I issue this (with GIT_TRACE=1), I get this:\n\n-- snip --\nC:\\Users\\me>set GIT_TRACE=1\n\nC:\\Users\\me>git ls-remote https://github.com/user/repository.git\n14:14:01.717354 git.c:348               trace: built-in: git 'ls-remote' 'https://github.com/user/repository.git'\n14:14:01.718331 run-command.c:343       trace: run_command: 'git-remote-https' 'https://github.com/user/repository.git' 'https://github.com/user/repository.git'\n14:14:02.599651 run-command.c:343       trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r line </dev/tty && echo \"$line\"'\nUsername for 'https://github.com': 123\n14:14:06.822993 run-command.c:343       trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r -s line </dev/tty && echo \"$line\" && echo\n>/dev/tty'\nPassword for 'https://123@github.com':\nremote: Invalid username or password.\nfatal: Authentication failed for 'https://github.com/user/repository.git/'\n-- snap --\n\nSo at first I thought maybe you called\n\n\tC:\\Program Files\\Git\\mingw64\\bin\\git.exe\n\ndirectly, which is a user mistake that is unfortunately quite frequent,\nthe appropriate entry point is instead\n\n\tC:\\Program Files\\Git\\cmd\\git.exe\n\nBut even then, it succeeds for me (without having sh.exe nor bash.exe in\nthe PATH):\n\n-- snip --\nC:\\Users\\me>\"\\Program Files\"\\git\\mingw64\\bin\\git ls-remote https://github.com/user/repository.git\n14:22:44.320489 git.c:348               trace: built-in: git 'ls-remote' 'https://github.com/user/repository.git'\n14:22:44.321470 run-command.c:343       trace: run_command: 'git-remote-https' 'https://github.com/user/repository.git' 'https://github.com/user/repository.git'\n14:22:44.990258 run-command.c:343       trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r line </dev/tty && echo \"$line\"'\nUsername for 'https://github.com': 123\n14:22:45.840206 run-command.c:343       trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r -s line </dev/tty && echo \"$line\" && echo >/dev/tty'\nPassword for 'https://123@github.com':\nremote: Invalid username or password.\nfatal: Authentication failed for 'https://github.com/user/repository.git/'\n-- snap --\n\nMaybe your setup has something funky going on that my setup lacks.\n\nLastly, for the record, the best way to report bugs in Git for Windows is\nthrough the bug tracker at https://github.com/git-for-windows/git/issues.\nI tried to make this obvious on Git for Windows' home page at\nhttps://git-for-windows.github.io/#contribute.\n\nMaybe you have an idea how I could make it more obvious to users who\nprefer visiting StackOverflow over visiting Git for Windows' home page?\n\nCiao,\nJohannes\n"}]}