问题
I am using GitHub. I created a repository and cloned it on my Ubuntu machine.
I have made an entry in the .netrc
file as follows:
machine https://github.com/xxx/yyy.git
login xxx
xxx
I am expecting that Git will not ask me for the username and password after this entry in the .netrc
file. But Git prompts for credentials even after this.
Am I missing something?
回答1:
The ~/.netrc
(or %HOME%\_netrc
on Windows) file isn't enough.
You would need to
- copy the git-credential-netrc file anywhere in your
$PATH
/%PATH%
, add:
cd yourRepo git config credential.helper "netrc -d -v"
(You can remove -d
and -v
once it is working: those are debug flags)
use your login in the remote URL:
git set-url origin https://yourLogin@github.com/yourLogin/yourRepo
See "Git - How to use .netrc file on Windows to save user and password" for the general principle of a credential "netrc" helper (Git 1.8.3+).
来源:https://stackoverflow.com/questions/31609203/git-netrc-file-authentication-issue