7

I worked alone on a project versioned on Github, so for convenience I put something like this in my ~/.git/config file:

url = https://[email protected]/COMPANY/PROJECT.git

This way git asks only for password on pull/push. But now more people have to push and pull, so we thought this would make git ask also for user name:

url = https://github.com/COMPANY/PROJECT.git

But instead git asks for nothing now and this is a sample result of git pull:

error: The requested URL returned error: 403 while accessing https://github.com/COMPANY/PROJECT.git/info/refs

fatal: HTTP request failed

How can git be forced to ask for user name and password as expected?

2
  • Did you consider certificate-based authentication? Commented Oct 29, 2013 at 10:19
  • @Philipp I was wondering about trying some other authentication methods, but for now I'd like to make the most basic one work. Commented Oct 29, 2013 at 10:53

2 Answers 2

4

I work on some different servers now and I've noticed that this issue affects git 1.7.0.4, but not the newer 1.7.9.5. So anyone experiencing the same problem should upgrade their git if possible.

@jszakmeister suggested asking the git mailing list, but having read this stackoverflow thread and this github page I think there's no point, it looks like a known problem without a good known solution. Github say they recommend git 1.7.10 and people in the stackoverflow discussion suggest things that don't really solve my problem. So I guess the only option is updating your git - let consider that the solution and this question answered.

Sign up to request clarification or add additional context in comments.

2 Comments

Confirmed. Was using 1.7.1 and had this same problem; switched to 2.10.2 and it works fine now, prompting for username and password as desired.
0

Are you using a credential helper? What does git config --get credential.helper show? If it shows something, then perhaps the information is being cached by the credential helper. One way of removing it would be:

printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT.git\nusername=MYUSERNAME\n\n" |
    git credential fill

It it prompts you for the password, then it's not cached in that particular form. It could be that it was cached without the .git on the end:

printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT\nusername=MYUSERNAME\n\n" |
    git credential fill

You can remove the credential with:

printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT.git\nusername=MYUSERNAME\n\n" |
    git credential remove

or, if no '.git' was present on the url:

printf "protocol=https\nhost=github.com\npath=COMPANY/PROJECT\nusername=MYUSERNAME\n\n" |
    git credential remove

Note that the only difference between these two commands and the above commands is that git credential fill became git credential remove. Also, if you post any data that comes from the git credential fill command, make sure to obscure your username and password.

If none of that helps, you may need to look at your ~/.gitconfig. You may have some credential.<url> blocks set up as outlined in this man page. Alternatively, you might be able to use that to alter the username.

8 Comments

We don't have credential helper installed, so it's not it unfortunately.
Are you sure? Did you try git config --get credential.helper? Most new installs do install one.
Oooh... GitHub may not be behaving correctly here, and outright denying you access instead of prompting for a username. I seem to recall this being an issue.
Hm, GitHub specific issue then... I'll google some more looking for Github this time. As for the credential helper, the command you posted returns nothing, also "git credential fill" returns "git: 'credential' is not a git command." so I'm positive we don't have the helper enabled.
@rafal-g this is not github specific, I got the same issue with bitbucket and git 1.7.1
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.