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?
netrc file format is simple: you specify lines with a machine name and follow that with the login and password that are associated with that machine. Each field is provided as a sequence of letters that ends with a space or newline. Since 7.84. 0, curl also supports quoted strings.
You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.
netrc — Access to git repo without typing password any time (for MacOSX). We're usually using local git configuration to store username and password for access. Especially if you're using https instead of ssh. Most of us are using gihub/gitlab/bitbucket as regular git repositories.
To reset your cached credentials so that Git prompts you to enter your credentials, access the Credential Manager in the Windows Control Panel under User Accounts > Credential Manager. Look for the GitHub entry and delete it.
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://[email protected]/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+).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With