0

I've set user.name and user.email in the config when user.name didn't work, but I am still prompted for my username every time I push/pull from remote.

$ git config user.name 'myemail@example.com'
$ git config user.email 'myemail@example.com'
$ git pull
Username for 'https://example.com': 

How can I skip that prompt?

I still want to be forced to enter a password every time.

theonlygusti
  • 11,032
  • 11
  • 64
  • 119
  • @Ben your answer on that question is the same as bk2204's answer on this one. I will probably accept bk2204's answer once I confirm it. I didn't find that question when I was searching for an answer before I posted my question, it's the same question. Unfortunately most of the answers on it aren't useful for me. It probably still counts as a duplicate though. – theonlygusti Nov 02 '19 at 19:25

3 Answers3

3

user.name and user.email have nothing to do with authentication. They represent the values that should be stored in your commits; that is, your name and email address as stored in the author and committer fields and as viewed in git log.

user.name should be your personal name; that is, some form of the name that other humans call you by.

For authentication, you can either use a username in the URL, such as https://myemail%40example.com@example.com/owner/repo.git, or you can run git config credential.https://example.com/.username myemail@example.com. Note that if you put the value in the URL, you need to percent-encode any relevant characters, as I've demonstrated.

bk2204
  • 64,793
  • 6
  • 84
  • 100
  • If the git repository is located at `https://example.com/path/to/repo.git`, do I specify that whole URL in the config – theonlygusti Nov 02 '19 at 19:23
  • You would edit `.git/config` to adjust the repository URL to include the `username@` portion as mentioned. – bk2204 Nov 02 '19 at 19:28
  • I mean, does the config store the username per-domain or per-repository. Your example command is: `git config credential.https://example.com/.username myemail@example.com`, but should it be `git config credential.https://example.com/path/to/repo.git.username myemail@example.com` for the remote at `https://example.com/path/to/repo.git` ? – theonlygusti Nov 02 '19 at 19:46
  • Unless you have a good reason, use just the portion of the URL with the hostname, although either is acceptable. See `gitcredential(7)` for more details. – bk2204 Nov 03 '19 at 02:19
  • Why is the url method recommended? – theonlygusti Nov 04 '19 at 08:44
0

you can do that using

git config --global credential.helper store

for more information and settings check this link: freecodecamp.org

Safwan Mh
  • 66
  • 8
-1

You're missing the --global flag to save that in in your global git config. To also cache your username for git push, see Git asks for username every time I push

Ben
  • 5,952
  • 4
  • 33
  • 44