Git .netrc file authentication issue

混江龙づ霸主 提交于 2019-12-05 04:55:21

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!