简体   繁体   中英

Git .netrc file authentication issue

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?

The ~/.netrc (or %HOME%\_netrc on Windows) file isn't enough.

It is best to use that file encrypted , with gpg + netrc alone, as I did here .

Or to use a script managing the encryption.
You would need, in that second case, to:

  • copy the git-credential-netrc.perl 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+).

正如@sschuberth 提到的删除协议 http:// 或 https:// 为我工作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM