0

Currently I have an entry like this in my .git/config file:

url = https://LarryMartell@github.com/...

When I pull it prompts me for a password. What I want is for it to prompt me for both a username and password so multiple people can pull. If I remove the LarryMartell from the url in the config file I get a 403 Forbidden

Here is my git config file:

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = https://LarryMartell@github.com/...
[branch "master"]
    remote = origin
    merge = refs/heads/master
Larry Martell
  • 3,526
  • 6
  • 40
  • 76
  • You get the 403; do other people going to `https://github.com/...` get the 403? Is there something else in your git configuration that keeps a username around that may cause the 403? –  Aug 29 '17 at 01:34
  • 1
    Does https://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed help? –  Aug 29 '17 at 01:35
  • NB: usually, it's `pull from` and `push to`. I think you mean `pull from`; just to avoid confusion. –  Aug 29 '17 at 01:35
  • Everyone gets the 403. I added the entire config file to the question. That other question says to change from http to ssh. I tried that and get `Permission denied (publickey).` – Larry Martell Aug 29 '17 at 01:41
  • The publickey message indicates one should upload their public ssh key to GitHub. Possibly not what you immediately want to do. –  Aug 29 '17 at 01:51
  • No I want each user to have to enter their creds from the command line for every pull – Larry Martell Aug 29 '17 at 01:53
  • Using https usually works for me, but I don't have a `[remote]` section in my git config: I clone directly from GitHub (in case of a private repo), and that seems to set things up correctly. –  Aug 29 '17 at 01:57
  • 1
    "I want each user to have to enter their creds from the command line for every pull": seems a bit odd. Can I ask why, out of curiosity? –  Aug 29 '17 at 01:58
  • This is for our production deployment. Multiple people are allowed to do deployments. I know could create some global user that everyone knows the password for, but I did not think having git prompt for the username would be this difficult. – Larry Martell Aug 29 '17 at 03:19
  • My curiosity is actually: why bother your users with having to enter their credentials every time? I assume each user is independent, and can therefore have their own private/public key pair. I'm not saying you should do this, but as a user, I would be annoyed having to enter my user/password each time (and an accidental keylogger would love this). There is, of course `[credential]\n helper = cache --timeout=86400` in `.gitconfig` for that. –  Aug 29 '17 at 03:57
  • Can you clone the repository over https without the user-name in the url? –  Aug 29 '17 at 04:03
  • Additionally, what is your `git` version? –  Aug 29 '17 at 04:06
  • Git version is 1.7.1. Yes I can clone the repo over https without the user-name in the url. – Larry Martell Aug 29 '17 at 09:45

1 Answers1

2

If you can, upgrade your git version.

Most answers on the internet (StackOverflow largely), suggest to do exactly as you do now, with the username in the URL. More recent versions of git allow what you want.

I would close this as a duplicate of, for example, Pushing to Git returning Error Code 403 fatal: HTTP request failed , but you'd have to scroll down to the eight answer to find the suggestion to upgrade git. The top answers suggest either the ssh route, or the https://@github.com route.

That eight answer provides a link to GitHub's help page on this as well: https cloning errors

Quoting from that:

There's no minimum Git version necessary to interact with GitHub, but we've found version 1.7.10 to be a comfortable stable version that's available on many platforms

I'll have to assume that "comfortable stable" here means that you can do what you want with this version.


If you can't or don't want to upgrade, I'm afraid you're stuck with the current work-arounds, as older git versions simply don't seem to support this.

  • I am on CentOS 6.5 that comes with git version 1.7.1. I tried to build 2.14.1 from source but that failed with `/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/share/locale' Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3. BEGIN failed--compilation aborted at Makefile.PL line 3.` – Larry Martell Aug 29 '17 at 12:23
  • @LarryMartell That error is searchable, and otherwise a different, new question. –  Aug 29 '17 at 12:26
  • Yes, googled error, installed perl-devel, then was able to build, and now it works as desired, prompting for username and password on command line. Thanks so much! – Larry Martell Aug 29 '17 at 12:34